@zerohash-sdk/fiat-account-link-js
v1.3.1
Published
A JavaScript SDK that enables frontend applications to seamlessly integrate with the Connect Fiat Account Link product.
Readme
@zerohash-sdk/fiat-account-link-js
A JavaScript SDK that enables frontend applications to seamlessly integrate with the Connect Fiat Account Link product.
Connect Fiat Account Link provides a secure, customizable flow for linking external bank accounts directly within your application.
Installation
Via NPM (recommended)
npm install @zerohash-sdk/fiat-account-link-jsimport { FiatAccountLink } from '@zerohash-sdk/fiat-account-link-js';Via CDN
<script
type="module"
src="https://sdk.connect.xyz/fiat-account-link-web/index.js"
></script>Or import directly in your JavaScript code:
import { FiatAccountLink } from 'https://sdk.connect.xyz/fiat-account-link-web/index.js';Getting Started
1. Import the FiatAccountLink module
import { FiatAccountLink } from '@zerohash-sdk/fiat-account-link-js';2. Initialize and render the widget
const fiatAccountLink = new FiatAccountLink({
jwt: 'your-jwt-token',
env: 'prod',
theme: 'auto',
onCompleted: ({ externalAccountId, institutionName }) => {
console.log('Account linked:', externalAccountId, institutionName);
},
onError: ({ errorCode, reason }) => {
console.error('Error:', errorCode, 'Reason:', reason);
},
onClose: () => console.log('Widget closed'),
onEvent: ({ type, data }) => console.log('Event:', type, data),
onLoaded: () => console.log('Widget loaded and ready'),
});
await fiatAccountLink.render(document.getElementById('fiat-account-link-container'));
fiatAccountLink.destroy();2.1 Using TypeScript (optional)
import { FiatAccountLink, FiatAccountLinkConfig } from '@zerohash-sdk/fiat-account-link-js';
const config: FiatAccountLinkConfig = {
jwt: 'your-jwt-token',
env: 'cert',
onCompleted: ({ externalAccountId, institutionName }) => {
console.log(externalAccountId, institutionName);
},
};
const fiatAccountLink = new FiatAccountLink(config);
await fiatAccountLink.render(document.getElementById('container')!);API Reference
Configuration
| Prop | Type | Required | Default | Description |
| ------------- | -------------------------------------------------- | -------- | -------- | ---------------------------------------------------- |
| jwt | string | Yes | - | JWT token for authentication with Connect |
| env | "prod" \| "cert" \| "dev" \| "local" | No | "prod" | Target environment |
| theme | "auto" \| "light" \| "dark" | No | "auto" | Theme mode for the interface |
| onCompleted | ({ externalAccountId, institutionName }) => void | No | - | Callback when account linking completes successfully |
| onError | ({ errorCode, reason }) => void | No | - | Callback for error events |
| onClose | () => void | No | - | Callback when the widget is closed |
| onEvent | ({ type, data }) => void | No | - | Callback for general events |
| onLoaded | () => void | No | - | Callback when the widget is loaded and ready |
Methods
render(container: HTMLElement): Promise<void>
updateConfig(config: Partial<FiatAccountLinkConfig>): void
destroy(): void
isRendered(): boolean
getConfig(): FiatAccountLinkConfig
Browser Support
- Chrome/Edge 90+
- Firefox 88+
- Safari 14+
- All modern browsers with Web Components support
More Information & Support
For comprehensive documentation or support about Connect, visit our Documentation Page.
