Loading...
Loading...
The Quiltt React SDK provides Components and Hooks for seamless integration of the Quiltt Connector into your React app.
For full documentation, additional examples and the source code, see the Quiltt React SDK on GitHub.
$ npm install @quiltt/react
$ pnpm add @quiltt/react
$ yarn add @quiltt/react
To load the Connector for use by a pre-existing end-user, you'll need to pass a valid Session token. See the Authentication guide for more information on generating Session tokens.
The QuilttProvider is the easiest way to pass a Session token to your React app.
import { QuilttProvider } from '@quiltt/react'
export const App = () => {
// See https://www.quiltt.dev/authentication/issuing-session-tokens
const sessionToken = '<SESSION_TOKEN_FROM_SERVER>'
return(
<QuilttProvider token={sessionToken}>
{children}
</QuilttProvider>
)
}
export default App
With the QuilttProvider handling authentication, your QuilttButton and QuilttContainer components will now automatically use the imported Session token.
For more granular access, including the ability to read, import and revoke Session tokens, use the useQuilttSession hook.
import { useCallback, useEffect } from 'react'
import { useQuilttSession } from '@quiltt/react'
const App = () => {
const { session, importSession, revokeSession } = useQuilttSession()
// See https://www.quiltt.dev/authentication/issuing-session-tokens
const sessionToken = '<SESSION_TOKEN_FROM_SERVER>'
// Import session from API call, local storage, query param, etc.
useEffect(() => {
importSession(sessionToken)
}, [importSession, sessionToken])
console.log('Authenticated Profile ID: ', session?.sub)
// Revoke and clear the Quiltt session
const logOut = useCallback(() => {
revokeSession()
// Do other stuff...
}, [revokeSession])
return (
<>
{session && <button onClick={logOut}>Log Out</button>}
{children}
</>
)
}
export default App
import { QuilttButton } from '@quiltt/react'
export const MyComponent = () => {
const handleLoad = (metadata) => console.log(`Connector ${metadata.connectorId} loaded!`)
const handleExitSuccess = (metadata) => console.log('Successfully added: ', metadata.connectionId)
return (
<QuilttButton
connectorId="<CONNECTOR_ID>"
onLoad={handleLoad}
onExitSuccess={handleExitSuccess}
// ... other props to pass through to the launcher <button>
>
Add
</QuilttButton>
)
}
export default App
import { QuilttButton } from '@quiltt/react'
export const MyComponent = () => {
const handleExitSuccess = (metadata) => {
console.log('Successfully reconnected: ', metadata.connectionId)
}
return (
<QuilttButton
connectorId="<CONNECTOR_ID>"
connectionId="<CONNECTION_ID>"
onExitSuccess={handleExitSuccess}
// ... other props to pass through to the launcher <button>
>
Reconnect
</QuilttButton>
)
}
import { QuilttButton } from '@quiltt/react'
export const MyComponent = () => {
const handleExitSuccess = (metadata) => {
console.log('Successfully reconnected: ', metadata.connectionId)
}
return (
<QuilttButton
connectorId="<CONNECTOR_ID>"
institution="<SEARCH_TERM>"
onExitSuccess={handleExitSuccess}
// ... other props to pass through to the launcher <button>
>
Reconnect
</QuilttButton>
)
}
import { QuilttContainer } from '@quiltt/react'
export const MyComponent = () => {
const handleLoad = () => console.log('Connector loaded!')
const handleExitSuccess = (metadata) => console.log('Successfully added: ', metadata.connectionId)
return (
<QuilttContainer
connectorId="<CONNECTOR_ID>"
onLoad={handleLoad}
onExitSuccess={handleExitSuccess}
className="my-css-class"
styles={{ height: '100%' }}
// ... other props to pass through to the container <div>
/>
)
}
export default App
import { QuilttContainer } from '@quiltt/react'
export const MyComponent = () => {
const handleExitSuccess = (metadata) => {
console.log('Successfully reconected: ', metadata.connectionId)
}
return (
<QuilttContainer
connectorId="<CONNECTOR_ID>"
connectionId="<CONNECTION_ID>"
onExitSuccess={handleExitSuccess}
className="my-css-class"
styles={{ height: '100%' }}
// ... other props to pass through to the container <div>
/>
)
}
export default App
import { QuilttContainer } from '@quiltt/react'
export const MyComponent = () => {
const handleExitSuccess = (metadata) => {
console.log('Successfully reconected: ', metadata.connectionId)
}
return (
<QuilttContainer
connectorId="<CONNECTOR_ID>"
institution="<SEARCH_TERM>"
onExitSuccess={handleExitSuccess}
className="my-css-class"
styles={{ height: '100%' }}
// ... other props to pass through to the container <div>
/>
)
}
export default App
Use the useQuilttResolvable hook to check if external provider institution IDs (e.g., Plaid) are supported to your connector.
Contact Quiltt Support to enable access to this feature.
import { useQuilttResolvable } from '@quiltt/react'
import { useEffect } from 'react'
function ResolvableConnector({ plaidInstitutionId, children }) {
const { checkResolvable, isResolvable, isLoading } = useQuilttResolvable('my-connector-id')
useEffect(() => {
checkResolvable({ plaid: plaidInstitutionId })
}, [plaidInstitutionId])
if (isLoading) return <div>Checking...</div>
if (!isResolvable) return null
return <>{children}</>
}
// Usage
<ResolvableConnector plaidInstitutionId="ins_3">
<QuilttButton connectorId="my-connector-id">Connect through Quiltt</QuilttButton>
</ResolvableConnector>
The example above will only render the Quiltt launcher button if your Plaid-enabled Connector supports connecting to Chase.
The React package comes bundled with the @quiltt/core package, which contains type definitions for all components and hooks.
See the definition file on GitHub
For developers looking to quickly bootstrap a Next.js project with Quiltt integration, we offer a pre-configured template:
This template provides a solid foundation for building fintech applications with Quiltt and Next.js. It includes:
To get started with the template, clone the repository and follow the setup instructions in the README. This can significantly speed up your development process and ensure you're following best practices for Quiltt integration from the start.