Web SDK
Embed the Connect Widget into your web application using the Web SDK.
To refer to the previous Web SDK, see the legacy documentation.
Prerequisites
Before integrating the SDK, ensure you have:
- An account on the Client Dashboard
- A web application built with your preferred framework or vanilla JavaScript
Installation
Install the SDK using npm or yarn:
- npm
- yarn
_10npm install @mxenabled/web-connect-widget-sdk
_10yarn add @mxenabled/web-connect-widget-sdk
Backend Setup
Create a backend endpoint that calls the Platform API to generate a widget URL. Set widget_type to connect_widget.
Retrieve the Widget URL
Call your backend endpoint from your web application to retrieve the widget URL.
Render a Container Element
Add an HTML element where the Connect Widget will be mounted. This container must be available in the DOM before you initialize the widget.
Initialize and Mount the Widget
Import the SDK, call ConnectWidget with the required properties, then mount the widget.
| Option | Type | Required | Description |
|---|---|---|---|
containerSelector | string | Yes | CSS selector for the DOM element where the widget will be mounted. |
url | string | Yes | The Connect Widget URL generated from the Platform API. |
onEvent | function | Yes | Callback function invoked for widget interactions. For a complete list of events you can handle, see Widget Events. |
iframeProps | object | No | Custom properties for the iframe element (styling, attributes). |
_25import { ConnectWidget, type Event } from '@mxenabled/web-connect-widget-sdk';_25_25const handleEvent = (event: Event) => {_25 switch (event.type) {_25 case 'mx/connect/memberConnected':_25 console.log('OAuth requested with URL:', event.metadata);_25 break;_25_25 default:_25 console.log('Received event:', event.type, event.metadata);_25 }_25};_25_25const widget = ConnectWidget({_25 containerSelector: '#widget-container',_25 iframeProps: {_25 style: {_25 border: 'solid 1px black',_25 },_25 },_25 onEvent: handleEvent,_25 url: 'https://.....',_25});_25_25widget.mount();
Make a Connection
Once the widget is mounted, users can interact with it to connect their financial institution accounts.
Unmount the Widget
When you're done with the widget or need to remove it from the page, call the unmount method:
_10widget.unmount();
This removes the widget from the DOM and cleans up event listeners.
You've successfully embedded the Connect Widget in your web application using the Web SDK!
Next Steps
Return to Integrate using MX's Connect Widget.