@connect-xyz/withdraw-js

中文文档
0.54.13发布于 2026/11/04MITTypeScriptES Module零依赖近 30 天下载 2045

A JavaScript SDK that enables frontend applications to seamlessly integrate with the Connect Withdraw product.

原始使用文档
文档目录19 节
  1. Installation
  2. Via NPM (recommended)
  3. Via CDN
  4. Getting Started
  5. 1. Import the Withdraw module
  6. 1.1 Or import via CDN
  7. 2. Initialize the Withdraw module into Your App
  8. API Reference
  9. Withdraw widget Props
  10. Constructor
  11. Methods
  12. Callback Functions
  13. onError
  14. onClose
  15. onWithdrawal
  16. onEvent
  17. onLoaded
  18. Browser Support
  19. More Information & Support

@connect-xyz/withdraw-js

A JavaScript SDK that enables frontend applications to seamlessly integrate with the Connect Withdraw product.

Connect Withdraw provides a secure way for end users to withdraw their funds. Learn more in the Connect Withdraw documentation.

Installation

npm install @connect-xyz/withdraw-js
import { Withdraw } from '@connect-xyz/withdraw-js';

Via CDN

You can import the script in your index file and use the Withdraw class provided by it.

<script
  type="module"
  src="https://sdk.connect.xyz/withdraw-web/index.js"
></script>

Or you can directly import in your javascript code.

import { Withdraw } from 'https://sdk.connect.xyz/withdraw-web/index.js';

Getting Started

Follow these simple steps to integrate Connect Withdraw into your frontend application:

1. Import the Withdraw module

import { Withdraw } from '@connect-xyz/withdraw-js';

1.1 Or import via CDN

import { Withdraw } from 'https://sdk.connect.xyz/withdraw-web/index.js';

2. Initialize the Withdraw module into Your App

// Create a Withdraw instance with configuration
const withdraw = new Withdraw({
  jwt: 'your-jwt-token',
  env: 'production', // or 'sandbox'
  onError: ({ errorCode, reason }) => {
    console.error('Withdraw error:', errorCode, 'Reason:', reason);
  },
  onClose: () => {
    console.log('Withdraw widget closed');
  },
  onWithdrawal: ({ data }) => {
    console.log('Withdrawal completed:', data);
  },
  onEvent: ({ type, data }) => {
    console.log('Event received:', type, data);
  },
  onLoaded: () => {
    console.log('Withdraw widget loaded and ready');
  },
});

// Render the widget to a container element
const container = document.getElementById('withdraw-container');
await withdraw.render(container);

// Update configuration dynamically
withdraw.updateConfig({
  jwt: 'new-jwt-token',
  onError: newErrorHandler,
});

// Check if rendered
if (withdraw.isRendered()) {
  console.log('Widget is active');
}

// Clean up when done
withdraw.destroy();

API Reference

Withdraw widget Props

PropTypeRequiredDefaultDescription
jwtstringYes-JWT token for authentication with Connect Withdraw
env"production" | "sandbox"No"production"Target environment
theme"auto" | "light" | "dark"No"auto"Theme mode for the interface
onError({ errorCode, reason }) => voidNo-Callback for error events
onClose() => voidNo-Callback when the widget is closed
onWithdrawal({ data }) => voidNo-Callback for withdrawal completed
onEvent({ type, data }) => voidNo-Callback for general events
onLoaded() => voidNo-Callback when the widget is loaded and ready

Constructor

new Withdraw(config: WithdrawConfig)

Creates a new Withdraw instance with the provided configuration.

Parameters

  • config (WithdrawConfig): Configuration object
    • jwt (string, required): JWT token for authentication
    • env (string, optional): Environment - 'production' (default) or 'sandbox'
    • theme (string, optional): Theme mode - 'auto' (default), 'light', or 'dark'
    • onError (function, optional): Error callback
    • onClose (function, optional): Close callback
    • onWithdrawal (function, optional): Withdrawal callback
    • onEvent (function, optional): General event callback
    • onLoaded (function, optional): Callback when widget is loaded and ready

Methods

render(container: HTMLElement): Promise<void>

Renders the Withdraw widget to the specified container element.

await withdraw.render(document.getElementById('withdraw-container'));

updateConfig(config: Partial<WithdrawConfig>): void

Updates the configuration of an already rendered widget.

withdraw.updateConfig({
  jwt: 'new-token',
  onError: newErrorHandler,
});

destroy(): void

Removes the widget from the DOM and cleans up resources.

withdraw.destroy();

isRendered(): boolean

Returns whether the widget is currently rendered.

if (withdraw.isRendered()) {
  // Widget is active
}

getConfig(): WithdrawConfig

Returns a copy of the current configuration.

const config = withdraw.getConfig();
console.log('Current JWT:', config.jwt);

Callback Functions

For detailed information about callback events and their payloads, see the Withdraw SDK Callbacks documentation.

onError

Called when an error occurs in the Withdraw widget.

onError: ({ errorCode, reason }) => {
  // errorCode: Error code
  // reason: Human-readable error description
};

onClose

Called when the Withdraw widget is closed by the user.

onClose: () => {
  // Handle close event
};

onWithdrawal

Called when a withdrawal is completed.

onWithdrawal: ({ data }) => {
  // data: Object containing withdrawal details
};

onEvent

Called for general events from the Withdraw widget.

onEvent: ({ type, data }) => {
  // type: Event type string
  // data: Event-specific data object
};

onLoaded

Called when the Withdraw widget has fully loaded and is ready for user interaction. This callback is useful for showing loading states or performing actions once the widget is initialized.

onLoaded: () => {
  // Widget is fully loaded and ready
};

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 Withdraw, visit our Documentation Page.

版本与发布记录

@connect-xyz/withdraw-js 共发布 90 个版本,首次发布于 2025/12/23;过去 12 个月发布了 90 个版本。

版本发布日期距今
0.54.13latest2026/11/049 天前
0.54.122026/10/3014 天前
0.54.112026/10/2717 天前
0.54.102026/10/2618 天前
0.54.92026/10/2421 天前
0.54.82026/10/2322 天前

关于 @connect-xyz/withdraw-js 的常见问题

@connect-xyz/withdraw-js 是什么?

A JavaScript SDK that enables frontend applications to seamlessly integrate with the Connect Withdraw product.

如何安装 @connect-xyz/withdraw-js?

在项目目录运行 npm install @connect-xyz/withdraw-js,或使用 pnpm add / yarn add / bun add。

@connect-xyz/withdraw-js 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@connect-xyz/withdraw-js 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@connect-xyz/withdraw-js 可以商用吗?

@connect-xyz/withdraw-js 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@connect-xyz/withdraw-js 的下载量有多少?

根据 npm 官方下载统计,@connect-xyz/withdraw-js 在 2026/10/11 – 2026/11/09 这 30 天内被下载 2,045 次,日均约 68 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@connect-xyz/withdraw-js 还在维护吗?

最新版本 0.54.13 发布于 2026/11/04(9 天前);至今共发布 90 个版本,其中过去 12 个月发布了 90 个;首次发布于 2025/12/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。