2.10.1 • Published 8 months ago

react-pluggy-connect v2.10.1

Weekly downloads
19
License
MIT
Repository
github
Last release
8 months ago

React Pluggy Connect SDK

React Bindings for our Pluggy Connect widget.

Setup

Using npm

npm install react-pluggy-connect

Using yarn

yarn add -S react-pluggy-connect

Import directly as an HTML <script>:

<script src="https://cdn.pluggy.ai/react-pluggy-connect/v2.8.1/react-pluggy-connect.js"></script>

Additionally, you can refer to the latest release by referencing the URL like so:

<script src="https://cdn.pluggy.ai/react-pluggy-connect/latest/react-pluggy-connect.js"></script>

Usage

The following is a minimal example to get started. See below for more all the available configurations.

For a more advanced, fully-working example you can use to get started right away, please check out our Connect Quickstart repo.

import React from 'react';
import ReactDOM from 'react-dom';

import { PluggyConnect } from 'react-pluggy-connect';

const Index = () => {
  const onSuccess = (itemData) => {
    // do something with the financial data
  };

  const onError = (error) => {
    // handle the error
  };

  return (
    <PluggyConnect
      connectToken={'your-connect-token-here'}
      onSuccess={onSuccess}
      onError={onError}
    />
  );
};

ReactDOM.render(<Index />, document.getElementById('root'));

Typescript Support

This project was built using Typescript so all typings are natively built-in.

However, for up-to-date Pluggy API typings to work, you'll need to install pluggy-js in your project as well, either as a dev or prod dependency.

npm install pluggy-js

Cordova Support

If your project is using Cordova (ie. Ionic Framework), be sure to also install the cordova-plugin-inappbrowser plugin.

This is necessary for links to be opened properly in the system browser, and for Oauth redirects to work as expected, without blocking the main app frame.

cordova plugin add cordova-plugin-inappbrowser

Configurations

The available configuration props are the following.

See our official Pluggy Connect widget documentation for more detailed information.

PropertyDescriptionRequired?TypeDefault
connectTokenYour Pluggy Connect token, which will be used to access the API.stringN/A
includeSandboxWhether to display Sandbox connectors in the Connector selection step (not intended for production use)🔲booleanfalse
allowConnectInBackgroundIf true, Connect can be minimized by the user to continue the connection with the component hidden🔲booleanfalse
allowFullscreenIf set to false, Connect won't be displayed as fullscreen on small/mobile screens, it will be displayed as a modal instead.🔲booleantrue
updateItemItem id to update. If specified, the modal will display directly the credentials form of the item to be updated.🔲stringN/A
connectorTypesList of Connector Types. If defined, only Connectors of the specified connector types will be listed.🔲ConnectorType[]N/A
connectorIdsList of Connector IDs. If defined, only Connectors of the specified connector IDs will be listed.🔲number[]N/A
countriesList of country codes (ISO-3166-1 alpha 2 format). If defined, only Connectors of the specified countries will be listed.🔲CountryCode[]N/A
productsIf defined, only the products specified in this array will be executed in the item creation (in order to be executed, you should have them enabled in your team subscription).🔲ProductType[]N/A
selectedConnectorIdIf specified and the Connector is present, after accepting terms, the widget will navigate to this Connector login form directly, skipping connectors selection step.🔲numberN/A
languageLanguage (2-letter ISO code string), used to display the widget. If not specified, or if the selected language is not supported, the default 'pt' will be used.🔲string'pt'
themeTheme to use for displaying the UI. Can be 'light' or 'dark'. Defaults to 'light'🔲'light' \| 'dark''light'
onSuccessFunction to execute when an Item has been created/updated successfully.🔲(data: { item: Item }) => void \| Promise<void>No op
onErrorFunction 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 \| Promise<void>No op
onOpenFunction to execute when the widget modal has been opened.🔲() => void \| Promise<void>No op
onCloseFunction to execute when the widget modal has been closed.🔲() => void \| Promise<void>No op
onEventFunction to execute to handle custom user interaction events. See the docs for more info.🔲Since v2.0.0: (payload: ConnectEventPayload) => void \| Promise<void> Until 1.x: (event: string, metadata: { timestamp: number }) => voidNo op
onLoadErrorFunction to execute when component has failed to load or render properly.🔲(error: Error) => void \| Promise<void>No op
innerRefRef function to access inner PluggyConnect instance. Gives access to instance methods such as .hide(). Parameter is passed as 'null' when component is unmounted.🔲(instance: InstanceType \| null: Error) => void \| Promise<void>No op

onEvent

This callback allows handling more specific events.

The property event inside the payload param of the onEvent callback, is the name of the current event triggered. The available events that can be handled through this method are:

Event nameDescription
'SUBMITTED_CONSENT'User has confirmed terms & privacy consent on the first Welcome screen.
'SELECTED_INSTITUTION'User has selected an institution to connect to, or has deselected it (ie. navigated back to previous step).
'SUBMITTED_LOGIN'User has submitted credentials to create the connection Item.
'SUBMITTED_MFA'User has submitted an extra parameter that has been requested by the institution to connect.
'LOGIN_SUCCESS'User has submitted credentials to create the connection Item successfully.
'LOGIN_MFA_SUCCESS'User has submitted an extra parameter that has been requested by the institution to connect successfully.
'LOGIN_STEP_COMPLETED'Successful completion of the login. User effectively logged in to the institution.
'ITEM_RESPONSE'Called every time the Item object is retrieved from Pluggy API, either when just created, updated, or each time it's retrieved to poll it's connection/execution status.

payload object has a property timestamp and some events extra data:

'SELECTED_INSTITUTION' has the connector property which is the connector selected by the user. 'LOGIN_SUCCESS' | 'LOGIN_MFA_SUCCESS' | 'LOGIN_STEP_COMPLETED' | 'ITEM_RESPONSE' events have the item property which is the item data related to the current connection.

Full event parameter type definition is:

type ConnectEventPayload = {
  timestamp: number;
} & (
  | {
      event: 'SUBMITTED_CONSENT' | 'SUBMITTED_LOGIN' | 'SUBMITTED_MFA';
    }
  | {
      event: 'SELECTED_INSTITUTION';
      connector: Connector | null;
    }
  | {
      event: 'LOGIN_SUCCESS' | 'LOGIN_MFA_SUCCESS' | 'LOGIN_STEP_COMPLETED' | 'ITEM_RESPONSE';
      item: Item;
    }
);
2.10.1

8 months ago

2.10.0

8 months ago

2.9.0

9 months ago

2.8.1

11 months ago

2.8.0

11 months ago

2.5.0

1 year ago

2.7.0

1 year ago

2.6.1

1 year ago

2.6.0

1 year ago

2.3.0

1 year ago

2.2.0

2 years ago

2.4.1

1 year ago

2.4.0

1 year ago

2.3.1

1 year ago

2.1.0

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.1.0-RC.1

3 years ago

0.1.0-RC.0

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1-alpha.2

3 years ago

0.0.1-alpha.1

3 years ago

0.0.1

3 years ago