use-pluggy-connect
v1.1.2
Published
React hook to integrate Pluggy Connect.
Downloads
28
Maintainers
Readme
use-pluggy-connect
React hook to integrate Pluggy Connect.
Install
npm install --save use-pluggy-connect
or
pnpm install --save use-pluggy-connect
or
yarn add use-pluggy-connect
or
bun install --save use-pluggy-connect
Usage
React
import React, { useCallback } from 'react'
import usePluggyConnect from 'use-pluggy-connect'
const App = () => {
const handleEvent = useCallback((payload) => {
console.log(`[Event]: ${payload}`)
}, [])
const { init, error, ready } = usePluggyConnect({
url: 'https://connect.pluggy.dev',
connectToken: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IJ9...',
onEvent: handleEvent,
})
if (!ready) {
return <div>Loading...</div>
}
if (error) {
return <div>Error: {error.message}</div>
}
return (
<div>
<button onClick={init}>Init</button>
</div>
)
}
export default App
Nextjs
'use client'
import usePluggyConnect from 'use-pluggy-connect'
export default function OpenPluggyButton() {
const { init } = usePluggyConnect({
connectToken:
'...',
})
return <button onClick={init}>Open Pluggy</button>
}
TODOS:
- [ ] Add tests
- [ ] Improve examples