react-plaid-link is a React component and hook library designed for integrating Plaid Link into React applications. As of version 4.1.1, it provides a modern, idiomatic React interface, primarily through the `usePlaidLink` hook, to manage the Plaid Link user experience. The library abstracts away the complexities of embedding and interacting with the Plaid Link JavaScript SDK, handling initialization, callbacks, and lifecycle events. It supports a wide range of React versions, from 16.8 up to 19, demonstrating active maintenance and compatibility with the latest React ecosystems. While the README does not specify a strict release cadence, the version history suggests regular updates to maintain compatibility and incorporate new Plaid Link features. Its primary differentiator is simplifying Plaid Link integration for React developers, offering explicit callback handlers for success, exit, and events, and clear mechanisms for handling OAuth flows.
npm install react-plaid-linkVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to integrate Plaid Link using the `usePlaidLink` hook, fetching a `link_token` (simulated), and handling success, exit, and loading callbacks. It correctly disables the button until Link is ready.
Consult the official GitHub release notes and migration guides provided by Plaid for `react-plaid-link` when upgrading across major versions to understand specific changes and required updates.
Implement a secure backend endpoint (e.g., Node.js, Python, Ruby) to call the Plaid API's `/link/token/create` endpoint and return the generated `link_token` to your frontend. Your React app should then fetch this token before initializing `usePlaidLink`.
Utilize a `React.useEffect` hook to conditionally call `open()` when the `ready` flag from `usePlaidLink` becomes `true` and a `receivedRedirectUri` is present, as shown in the library's OAuth examples.
Verify the `react` and `react-dom` versions in your `package.json` file. Update them to a compatible range if necessary and run `npm install` or `yarn install` to ensure correct resolution of peer dependencies.
Verify your backend is generating a valid, non-expired `link_token` using the Plaid API and that it's correctly passed to the `usePlaidLink` hook. Plaid Link tokens typically expire after 30 minutes, so fetch a fresh one for each new Link session.
Always check the `ready` boolean flag returned by `usePlaidLink` before calling `open()`. For example, `disabled={!ready}` on your button. Also, ensure `const { open, ready } = usePlaidLink(...)` correctly destructures the hook's return value.Ensure `usePlaidLink` is invoked directly within the top level of a functional React component or another custom hook, and not inside loops, conditions, or nested functions.
Check for errors during `usePlaidLink` initialization (e.g., `error` return value). Ensure your React environment is set up correctly and no other issues are preventing the hook from returning its expected object. This error is rare and often points to a deeper React environment problem.