Skip to content

pluggyai/use-pluggy-connect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

use-pluggy-connect

React hook to integrate Pluggy Connect.

NPM JavaScript Style Guide

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