README
Pluggy Connect SDK
Plain Javascript Wrapper for our Pluggy Connect widget.
Setup
Using npm
:
npm install pluggy-connect-sdk
Using yarn
:
yarn add -S pluggy-connect-sdk
Importing directly as an HTML <script>
:
<script src="https://cdn.pluggy.ai/pluggy-connect/v0.1.1/pluggy-connect.js"></script>
Additionally, you can refer to the latest
release by referencing the URL like so:
<script src="https://cdn.pluggy.ai/pluggy-connect/latest/pluggy-connect.js"></script>
Usage
The following is a minimal usage example:
import PluggyConnect from 'pluggy-connect-sdk';
// First, configure the instance to your needs
const pluggyConnect = new PluggyConnect({
connectToken: 'qwerty123...', // Your Pluggy API Key (required)
includeSandbox: false, // if set to 'true', sandbox connectors will be included
onSuccess: (itemData) => {
// Connection success callback handler
console.log('Yay! Pluggy connect success!', itemData);
},
onError: (error) => {
// Error callback handler
console.error('Whoops! Pluggy Connect error... ', error);
},
});
// Then, open it
pluggyConnect.init();
API
init
Opens the Pluggy Connect widget on a modal. Returns a Promise that resolves when it has been rendered, or throws if it has failed.
destroy
Manually destroys the current PluggyConnect instance. Useful to cleanup all connection resources. Note: usually this wouldn't be recommended, the instance should be created once and open/close it as needed. Returns a Promise that resolves when destroyed, or throws if it has failed for some reason.
Configurations
The following properties are available for configuration. For more info, please see our documentation to find the most up-to-date details.
Property | Description | Required? | Type | Default |
---|---|---|---|---|
connectToken |
Your Pluggy Connect token, which will be used to access the API. | ✅ | string |
N/A |
includeSandbox |
Whether to display Sandbox connectors in the Connector selection step (not intended for production use) | 🔲 | boolean |
false |
updateItem |
Item id to update. If specified, the modal will display directly the credentials form of the item to be updated. | 🔲 | string |
N/A |
connectorTypes |
List of Connector Types. If defined, only Connectors of the specified connector types will be listed. | 🔲 | ConnectorType[] |
N/A |
connectorIds |
List of Connector IDs. If defined, only Connectors of the specified connector IDs will be listed. | 🔲 | number[] |
N/A |
countries |
List of country codes (ISO-3166-1 alpha 2 format). If defined, only Connectors of the specified countries will be listed. | 🔲 | CountryCode[] |
N/A |
language |
Language ISO string used to display the widget. If not specified, the browser language will be used, falling back to 'en' if not supported. |
🔲 | string |
Browser language |
onSuccess |
Function to execute when an Item has been created/updated successfully. | 🔲 | (data: { item: Item }) => void |
No op |
onError |
Function to execute on a general error loading the widget, or when an Item creation/update status has not been successful. | 🔲 | (error: { message: string; data?: { item: Item } }) => void |
No op |
onOpen |
Function to execute when the widget modal has been opened. | 🔲 | () => void |
No op |
onClose |
Function to execute when the widget modal has been closed. | 🔲 | () => void |
No op |
onEvent |
Function to execute to handle custom user interaction events. See the docs for more info. | 🔲 | (event: string, metadata: { timestamp: number }) => void |
No op |
Quickstart example
You can find a fully working functional example in our Quickstarts repo, in the /html folder. Feel free to clone or fork it to quickly get started with your application!
Typescript Support
This project was built using Typescript so all typings are natively built-in.
However, for up-to-date Pluggy API typings, you'll need to install pluggy-js
in your project as
well, either as a dev or prod dependency.
npm install pluggy-js
Issues
We'll be glad if you report any issue you'd find in the issues section.
Contributing
All contributions welcome! Feel free to submit your PR and tag any of the Pluggyers for a quick review.