Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
react-plaid-link
Advanced tools
The react-plaid-link npm package is a React wrapper for Plaid Link, which is a quick and secure way to integrate with the Plaid API. It allows users to connect their bank accounts to your application, enabling functionalities like retrieving account balances, transaction histories, and more.
Initialize Plaid Link
This code demonstrates how to initialize Plaid Link in a React application. The `PlaidLink` component is configured with necessary props like `clientName`, `env`, `product`, `publicKey`, and `onSuccess` callback.
import React from 'react';
import { PlaidLink } from 'react-plaid-link';
const App = () => {
const onSuccess = (public_token, metadata) => {
console.log('Public Token: ', public_token);
console.log('Metadata: ', metadata);
};
return (
<PlaidLink
clientName="Your App Name"
env="sandbox"
product={['auth', 'transactions']}
publicKey="your_public_key"
onSuccess={onSuccess}
>
Connect a bank account
</PlaidLink>
);
};
export default App;
Handle onExit Callback
This code demonstrates how to handle the `onExit` callback, which is triggered when the user exits the Plaid Link flow. The `onExit` callback provides error information and metadata.
import React from 'react';
import { PlaidLink } from 'react-plaid-link';
const App = () => {
const onExit = (error, metadata) => {
console.log('Error: ', error);
console.log('Metadata: ', metadata);
};
return (
<PlaidLink
clientName="Your App Name"
env="sandbox"
product={['auth', 'transactions']}
publicKey="your_public_key"
onExit={onExit}
>
Connect a bank account
</PlaidLink>
);
};
export default App;
Handle onEvent Callback
This code demonstrates how to handle the `onEvent` callback, which is triggered for various events during the Plaid Link flow. The `onEvent` callback provides the event name and metadata.
import React from 'react';
import { PlaidLink } from 'react-plaid-link';
const App = () => {
const onEvent = (eventName, metadata) => {
console.log('Event Name: ', eventName);
console.log('Metadata: ', metadata);
};
return (
<PlaidLink
clientName="Your App Name"
env="sandbox"
product={['auth', 'transactions']}
publicKey="your_public_key"
onEvent={onEvent}
>
Connect a bank account
</PlaidLink>
);
};
export default App;
The react-stripe-elements package is a React wrapper for Stripe.js, allowing you to build custom payment forms with Stripe. It provides similar functionality in terms of integrating a third-party financial service into a React application, but it focuses on payment processing rather than bank account linking.
The react-paypal-button-v2 package is a React component for integrating PayPal's checkout buttons into your application. Like react-plaid-link, it simplifies the integration of a financial service, but it is specifically designed for handling PayPal transactions.
The react-google-login package is a React component for integrating Google login into your application. While it is not a financial service, it provides a similar user authentication flow, making it comparable in terms of user experience and integration complexity.
React hooks and components for integrating with the Plaid Link drop module
With npm
:
npm install react-plaid-link --save
With yarn
yarn add -S react-plaid-link
Please refer to the official Plaid Link docs for a more holistic understanding of the various Link options.
Head to the react-plaid-link
storybook to try it out for yourself, or
checkout:
This is the new and preferred approach for integrating with Plaid Link in React.
import React, { useCallback } from 'react';
import { usePlaidLink } from 'react-plaid-link';
const App = () => {
const onSuccess = useCallback((token, metadata) => {
// send token to server
}, []);
const config = {
clientName: 'Your app name',
env: 'sandbox',
product: ['auth', 'transactions'],
publicKey: '<YOUR_PLAID_PUBLIC_KEY>',
onSuccess,
// ...
};
const { open, ready, error } = usePlaidLink(config);
return (
<MyButton onClick={() => open()} disabled={!ready}>
Connect a bank account
</MyButton>
);
};
export default App;
import React from 'react';
import { PlaidLink } from 'react-plaid-link';
const App = () => {
const onSuccess = (token, metadata) => {
// send token to server
}
render() {
return (
<PlaidLink
clientName='Your app name'
env='sandbox'
product={['auth', 'transactions']}
publicKey='<YOUR_PLAID_PUBLIC_KEY>'
onSuccess={onSuccess}
>
Connect a bank account
</PlaidLink>
);
}
}
export default App;
Please refer to the official Plaid Link docs for a more holistic understanding of the various Link options.
// src/types/index.ts
interface PlaidLinkOptions {
clientName: string;
env: string;
publicKey: string;
product: Array<string>;
onSuccess: Function;
// optional
onExit?: Function;
onLoad?: Function;
onEvent?: Function;
countryCodes?: Array<string>;
language?: string;
token?: string;
userEmailAddress?: string;
userLegalName?: string;
webhook?: string;
linkCustomizationName?: string;
oauthNonce?: string;
oauthRedirectUri?: string;
oauthStateId?: string;
paymentToken?: string;
}
Typescript definitions for react-plaid-link
are built into the npm packge.
2.0.2
publicKey
prop and auto-generate PropTypes for React component (#87)FAQs
A React component for Plaid Link
The npm package react-plaid-link receives a total of 185,480 weekly downloads. As such, react-plaid-link popularity was classified as popular.
We found that react-plaid-link demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.