In your react-native project directory:
npm install --save react-native-plaid-link-sdk
When upgrading from a previous major version of this library, see the notes here for additional instructions.
Add Plaid to your project’s Podfile as follows (likely located at ios/Podfile). The latest version is .
pod 'Plaid', '~> <insert latest version>'
Then install your cocoapods dependencies:
(cd ios && pod install)
Add a Run Script build phase (after the [CP] Embed Pods Frameworks step) to your target as described in Plaid Link for iOS documentation. This strips simulator symbols from App Store release builds.
That's it if using a recent react-native version with autolinking support.
If using a version of react-native without autolinking support, then you will need to:
react-native link react-native-plaid-link-sdk
followed by
- In Xcode, in the project navigator, right click
Libraries▶Add Files to [your project's name] - Go to
node_modules▶react-native-plaid-link-sdk▶iosand addRNLinksdk.xcodeproj - In Xcode, in the project navigator, select your project. Add
libRNLinksdk.ato your project'sBuild Phases▶Link Binary With Libraries - Run your project (
Cmd+R)<
- Log into your Plaid Dashboard at the API page
- Next to Allowed Android package names click "Configure" then "Add New Android Package Name"
- Enter your package name, for example
com.plaid.example - Click "Save Changes", you may be prompted to re-enter your password
- Go to
android/app/src/main/java/<AppName>/MainApplication.java - Add
import com.plaid.PlaidPackage;to the imports section - Add
packages.add(new PlaidPackage());toList<ReactPackage> getPackages();
- Go to the project level
android/app/build.gradle - Make sure you are using a min sdk >= 21
- Use the latest Android link version
- Add the following dependencies:
dependencies {
...
implementation project(':react-native-plaid-link-sdk')
implementation 'com.plaid.link:sdk-core:<insert latest version>'
implementation 'com.squareup.okhttp3:okhttp-urlconnection:<insert at least version 4.x>'- Go to
android/settings.gradle - Add the following lines:
include ':react-native-plaid-link-sdk'
project(':react-native-plaid-link-sdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-plaid-link-sdk/android')To initialize Plaid Link, you will need to first create a link_token at /link/token/create.
After creating a link_token, you'll need to pass it into your app and use it to launch Link:
import { Text } from 'react-native';
import PlaidLink from 'react-native-plaid-link-sdk';
const MyPlaidComponent = () => {
return (
<PlaidLink
// Replace any of the following <#VARIABLE#>s according to your setup,
// for details see https://plaid.com/docs/quickstart/#client-side-link-configuration
token={<#GENERATED_LINK_TOKEN#>}
onSuccess={data => console.log('success: ', data)}
onExit={data => console.log('exit: ', data)}
>
<Text>Add Account</Text>
</PlaidLink>
);
};
If you configured your link_token with one or more European country codes and are using React Native iOS, your integration will require additional Link configuration parameters (oauthNonce, oauthRedirectUri, and oauthStateId) in order to support OAuth authentication flows. You will also need to configure a universal link. See OAuth requirements for more information.
The React Native Plaid module emits onEvent events throughout the account linking process — see details here. To receive these events in your React Native app, wrap the PlaidLink react component with the following in order to listen for those events:
import React from 'react';
import { Text, NativeEventEmitter, NativeModules } from 'react-native';
class PlaidEventContainer extends React.Component {
componentDidMount() {
const emitter = new NativeEventEmitter(Platform.OS === 'ios' ? NativeModules.RNLinksdk : NativeModules.PlaidAndroid);
this._listener = emitter.addListener('onEvent', (e) => console.log(e));
}
componentWillUnmount() {
if (this._listener) {
this._listener.remove();
}
}
render() {
return (
<PlaidLink
token={<#GENERATED_LINK_TOKEN#>}
onSuccess={data => console.log('success: ', data)}
onExit={data => console.log('exit: ', data)}
>
<Text>Add Account</Text>
</PlaidLink>
);
}
}
By default, PlaidLink renders a TouchableOpacity component. You may override the component used by passing component and componentProps. For example:
<PlaidLink
token = {<#GENERATED_LINK_TOKEN#>}
component= {Button}
componentProps = {{title: 'Add Account'}}
onSuccess = {(result) => {console.log('Success: ', result)}}
onError = {(result) => {console.log('Error: ', result)}}
>