Create a connection
OnRamp is Leen’s embeddable onboarding component that allows your users to easily create new connections or update existing connections. As an embeddable component, OnRamp is designed to be integrated directly into your application workflow.
Getting Started with Leen OnRamp
This guide will walk you through the steps to integrate OnRamp, Leen’s embeddable onboarding component, into your application. Here’s a quick overview of the steps involved:
- Create a connection invite token
- Initialize Leen’s OnRamp component
- Custom overrides (optional)
- Create Connections
Note: Currently, Leen’s OnRamp component only supports embedding into React applications. We can add support for other frameworks, please contact us to learn more.
Create Connection Invite Token
This step is for creating a new connection using OnRamp. If you want to update a connection, refer to the Update a connection with OnRamp guide.
You can provision a new token by making a POST request to the Create Connection Invite Token API with the following payload:
A connection invite token will be returned for a specific vendor - this token can be used to only create one new connection for the vendor specified in the payload.
-
you can optionally pass in any connection
options
, like you would when creating a new connection via our API. These options will not be visible to the user, but will directly be applied to the connection when it is created.
Initialize Leen's OnRamp component
Leen’s OnRamp component has been published to npm library and can be installed using npm, yarn, bun, or any other package manager.
Once installed, you can import the component into your React application and initialize it with the connection invite token. Here is an example of how you can use the OnRamp component in your React application:
Handle Response from OnRamp
Use the useEffect
hook with onRampResponse
to handle the response from the OnRamp component and perform any necessary actions in your application. Whenever onRampResponse
changes, the effect will run, allowing you to process the response data.
onRampResponse
will be an object of type LeenOnRampResponse
, which can be imported in your application as seen in the snippet above. For reference, here is what the response object would look like:
Catching and handling error events
OnRamp will also emit an error event when connection creation fails. You can catch this event and handle it accordingly in your application.
To do this, you can add an event listener for the leenConnectionError
event in your application like so:
Custom overrides (optional)
You can optionally override some settings for the OnRamp component. Specifically, you can change:
- Primary color (defualts to Leen’s brand colors)
- Logo (defaults to Leen’s logo)
- Docs URLs for specficic vendors (defaults to Leen’s docs)
Create Connections
That’s it! Your users should now be able to create new connections or update existing connection within your application. OnRamp will open up as a modal in your application and your users will be presented with an interface to provide the right credentials for the vendor - via secrets or OAuth.
Reference
For reference, we have created a public GitHub Repository showcasing how to integrate Leen OnRamp into a React application. This GitHub repo contains a simple React application that demonstrates how to use Leen OnRamp to create connections with vendors supported by Leen.