• Stars
    star
    264
  • Rank 154,267 (Top 4 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 8 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

React bindings for Plaid Link

react-plaid-link npm version

React hook and components for integrating with Plaid Link

Compatibility

React 16.8+

Install

With npm:

npm install --save react-plaid-link

With yarn

yarn add react-plaid-link

Documentation

Please refer to the official Plaid Link docs for a more holistic understanding of Plaid Link.

Examples

Head to the react-plaid-link storybook to try out a live demo.

See the examples folder for various complete source code examples.

Using React hooks

This is the preferred approach for integrating with Plaid Link in React.

Note: token can be null initially and then set once you fetch or generate a link_token asynchronously.

ℹ️ See a full source code examples of using hooks:

import { usePlaidLink } from 'react-plaid-link';

// ...

const { open, ready } = usePlaidLink({
  token: '<GENERATED_LINK_TOKEN>',
  onSuccess: (public_token, metadata) => {
    // send public_token to server
  },
});

return (
  <button onClick={() => open()} disabled={!ready}>
    Connect a bank account
  </button>
);

Available Link configuration options

ℹ️ See src/types/index.ts for exported types.

Please refer to the official Plaid Link docs for a more holistic understanding of the various Link options and the link_token.

usePlaidLink arguments

key type
token string | null
onSuccess (public_token: string, metadata: PlaidLinkOnSuccessMetadata) => void
onExit (error: null | PlaidLinkError, metadata: PlaidLinkOnExitMetadata) => void
onEvent (eventName: PlaidLinkStableEvent | string, metadata: PlaidLinkOnEventMetadata) => void
onLoad () => void
receivedRedirectUri string | null | undefined

usePlaidLink return value

key type
open () => void
ready boolean
error ErrorEvent | null
exit (options?: { force: boolean }, callback?: () => void) => void

OAuth / opening Link without a button click

Handling OAuth redirects requires opening Link without any user input (such as clicking a button). This can also be useful if you simply want Link to open immediately when your page or component renders.

ℹ️ See full source code example at examples/oauth.tsx

import { usePlaidLink } from 'react-plaid-link';

// ...

const { open, ready } = usePlaidLink(config);

// open Link immediately when ready
React.useEffect(() => {
  if (ready) {
    open();
  }
}, [ready, open]);

return <></>;

Usage with Wallet Onboard

Plaid Wallet Onboard uses similar patterns. See the Wallet Onboard docs for a holistic understanding on configuration and usage.

ℹ️ See a full source code example of using hooks with Wallet Onboard:

import { useEthereumProvider } from 'react-plaid-link/web3';

// ...

const onSuccess = useCallback(
  async provider => {
    const accounts = await provider.request({
      method: 'eth_accounts',
    });
    setAccounts(accounts);
  },
  [setAccounts]
);

const { open, ready } = useEthereumProvider({
  token:
    'https://plaid.com/docs/wallet-onboard/add-to-app/#enable-wallet-onboard-and-retrieve-a-link-token',
  chain: {
    chainId: '0x1',
    rpcUrl: '',
  },
  onSuccess,
});

return (
  <button onClick={() => open()} disabled={!ready}>
    Connect wallet
  </button>
);

useEthereumProvider arguments

key type
token string | null
chain ChainOption
onSuccess (provider: EIP1193Provider) => void
onExit (error: null | PlaidLinkError, metadata: PlaidLinkOnExitMetadata) => void
onLoad () => void
receivedRedirectUri string | null | undefined

useEthereumProvider return value

key type
open () => void
ready boolean
error ErrorEvent | null
getCurrentEthereumProvider (chainOption: ChainOption) => Promise<EIP1193Provider | null | undefined>
isProviderActive (provider: EIP1193Provider) => Promise<boolean>
disconnectEthereumProvider (provider: EIP1193Provider) => Promise<void>

Using the pre-built component instead of the usePlaidLink hook

If you cannot use React hooks for legacy reasons such as incompatibility with class components, you can use the PlaidLink component.

ℹ️ See full source code example at examples/component.tsx

import { PlaidLink } from "react-plaid-link";

const App extends React.Component {
  // ...
  render() {
    return (
      <PlaidLink
        token={this.state.token}
        onSuccess={this.onSuccess}
        // onEvent={...}
        // onExit={...}
      >
        Link your bank account
      </PlaidLink>
    );
  }
}

Typescript support

TypeScript definitions for react-plaid-link are built into the npm package. If you have previously installed @types/react-plaid-link before this package had types, please uninstall it in favor of built-in types.

More Repositories

1

quickstart

Get up and running with Plaid Link and the API in minutes
TypeScript
537
star
2

plaid-node

Node bindings for Plaid
TypeScript
518
star
3

pattern

An example end-to-end Plaid integration to create items and fetch transaction data
TypeScript
441
star
4

plaid-python

Python bindings for Plaid
Python
402
star
5

plaid-postman

Postman collection for the Plaid API
HTML
315
star
6

deprecated-link

This repository is now deprecated. To integrate with Plaid, visit the docs.
261
star
7

plaid-ruby

Ruby bindings for Plaid
Ruby
221
star
8

plaid-go

go bindings for Plaid
Go
194
star
9

deprecated-async-problem

🔀 Solutions and non-solutions to JavaScript's async problem
JavaScript
186
star
10

react-native-plaid-link-sdk

Plaid Link for React Native
TypeScript
170
star
11

plaid-java

Java bindings for Plaid
Java
124
star
12

plaid-link-ios

Plaid Link iOS SDK
Objective-C
116
star
13

plaid-link-android

Plaid Link Android SDK
Kotlin
100
star
14

tiny-quickstart

A minimal quickstart demonstrating Plaid Link, Balances, and OAuth
JavaScript
77
star
15

plaid-openapi

API version 2020-09-14
74
star
16

support

Plaid Support
66
star
17

plaid-link-examples

Plaid Link Webview, ReactNative examples
Objective-C
60
star
18

pattern-account-funding

Sample code to demonstrate Plaid-powered account funding use cases using the Auth, Identity, and Balance APIs. Includes examples of using Auth partners for end-to-end funds transfers.
TypeScript
44
star
19

envvar

Derive JavaScript values from environment variables
JavaScript
37
star
20

npmserve

fast npm installs for slow clients
Shell
36
star
21

npmserve-server

fast npm installs for slow clients
JavaScript
27
star
22

go-envvar

A go library for managing environment variables. Maps to typed values, supports required and optional vars with defaults.
Go
25
star
23

idv-quickstart

Get up and running with Plaid Identity Verification in minutes
CSS
22
star
24

tutorial-resources

Sample apps and material to go along with Plaid's tutorials
JavaScript
18
star
25

income-sample

Sample app for Income
TypeScript
15
star
26

account-funding-tutorial

TypeScript
13
star
27

sandbox-custom-users

JSON files specifying custom users suitable for testing Plaid integrations on Sandbox
Python
13
star
28

nockingbird

Declarative HTTP mocking (for use with Nock)
CoffeeScript
13
star
29

core-exchange

The Core Exchange spec and generated server code
MDX
12
star
30

pattern-transfers

TypeScript
11
star
31

payment-initiation-pattern-app

Payment Initiation demo app for Europe, based on Plaid Pattern
TypeScript
6
star
32

credit-attributes

Attributes that can be calculated using Plaid's credit products
Python
4
star
33

plaid-node-legacy

⚠️This library has been deprecated and archived. Our current libraries can be found at https://plaid.com/docs/libraries/ or https://github.com/plaid
JavaScript
4
star
34

assets-attributes

Attributes that can be calculated using a Plaid Asset Report
Python
3
star
35

plaid-java-legacy

⚠️This library has been deprecated and archived. Our current libraries can be found at https://plaid.com/docs/libraries/ or https://github.com/plaid
Java
3
star
36

plaid-python-legacy

⚠️This library has been deprecated and archived. Our current libraries can be found at https://plaid.com/docs/libraries/ or https://github.com/plaid
Python
3
star
37

plaid-ruby-legacy

⚠️This library has been deprecated and archived. Our current libraries can be found at https://plaid.com/docs/libraries/ or https://github.com/plaid
Ruby
2
star
38

.github

1
star
39

plaid-go-legacy

⚠️This library has been deprecated and archived. Our current libraries can be found at https://plaid.com/docs/libraries/ or https://github.com/plaid
1
star