Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.withbenji.com/llms.txt

Use this file to discover all available pages before exploring further.

Installing the Benji Connect SDK

The Benji Connect SDK can be added to your application by including the SDK script in your HTML head.
<script src="https://d1ochlq3jv1msw.cloudfront.net/connect/sdk/connect-sdk.js"></script>
or by installing the package via npm
npm install @benji-money/connect-sdk
or by installing the package via yarn
yarn add @benji-money/connect-sdk
or by installing the package via pnpm
pnpm add @benji-money/connect-sdk
Note that you will be able to access the above packages/scripts once authorized to use the Benji SDKs. Contact your account manager for additional info.

How the Benji Connect SDK loads Connect

When you call open(), the Benji Connect SDK creates a modal overlay and loads the Connect experience inside it.

Initializing the Benji Connect SDK

The Benji Connect SDK is initialized with the following parameters:
environment
string
required
Environment for the Connect flow: development | sandbox | production.
token
string
required
Connect token from the Create Token API.
onSuccess
callback function
Called when the flow completes successfully (FLOW_SUCCESS). Receives the exchange token and metadata.
onExit
callback function
Called when the user leaves the Connect UI (FLOW_EXIT), whether or not onSuccess ran.
onError
callback function
Called when an error is reported from the Connect flow (ERROR).
onEvent
callback function
Called for mid-flow and auxiliary events (e.g. AUTH_SUCCESS). See Methods & Events.
Types are optional. The same runtime behavior applies to JavaScript and TypeScript; TypeScript users can import types from @benji-money/connect-sdk for autocomplete.
import { ConnectSDK } from "@benji-money/connect-sdk";

let sdk = null;

function initializeSDK(token) {
  sdk = new ConnectSDK({
    environment: "sandbox",
    token: token,

    onSuccess: (token, metadata) => {
      console.log("Benji Connect successful");
      // Exchange `token` via Exchange Token API; use metadata for UI
    },

    onError: (error, errorId, metadata) => {
      console.log("Benji Connect onError", error, errorId);
    },

    onExit: (metadata) => {
      console.log("Benji Connect onExit", metadata.trigger);
    },

    onEvent: (type, metadata) => {
      console.log("Benji Connect onEvent", type);
    },
  });
}
To open the UI after initialization, call await sdk.open() (see Methods & Events).