@dwolla/react-drop-ins

中文文档
1.2.0发布于 2026/04/27MITTypeScriptESM + CJS零依赖近 30 天下载 4231

React bindings for Dwolla's drop-in components

原始使用文档
文档目录9 节
  1. Table of Contents
  2. Installation
  3. Examples
  4. Storybook
  5. Usage
  6. Configuration options for useDwollaWeb
  7. Changelog
  8. Community
  9. Additional Resources

react-drop-ins npm version

React bindings for Dwolla's drop-in components. This library provides a React hook for importing the dwolla-web.js library and a set of React components for using the drop-in components.

Table of Contents

Installation

# using npm
$ npm i @dwolla/react-drop-ins

# using yarn
$ yarn add @dwolla/react-drop-ins

# using pnpm
$ pnpm add @dwolla/react-drop-ins

Examples

An example React component demonstrating how to use the library and the DwollaCustomerCreate component can be found in the examples directory.

Storybook

View a live demo of all components. Switch to the Docs tab and click on Show code to see the implementation code for each component.

Usage

In order to use this package, you will first need to set up your application to be able to make calls to the Dwolla API. You can use one of our SDKs in your preferred language to get up and running quickly.

Then you will need to set up a server-side endpoint for generating client tokens. You can do this by following the steps in the Generate a Client Token guide.

You're now ready to start using the package!

Create a configuration object for the useDwollaWeb hook as shown in the code example below. This hook will import the dwolla-web.js library and handle any errors that may occur during import.

The full list of configuration options for the hook can be found in the table below.

// Import the useDwollaWeb hook and the DwollaCustomerCreate component
import { DwollaCustomerCreate, useDwollaWeb } from '@dwolla/react-drop-ins';
import type { DwollaWebOptions } from '@dwolla/react-drop-ins';

// Create configuration for the useDwollaWeb hook
const config: DwollaWebOptions = {
environment: 'sandbox',
onError: function error() {
    console.log('Error');
},
onSuccess: function success() {
    console.log('Success');
},
tokenUrl: '/yourTokenUrl'
};

const App = () => {
  // Initialize the useDwollaWeb hook
  const { ready, error } = useDwollaWeb(config);

  // Wait for the hook to be ready
  if (!ready) return <div>Loading...</div>;

  // Handle errors
  if (error) return <div>Error</div>;

  // Render the DwollaCustomerCreate component when ready
  return (
    <>
      <DwollaCustomerCreate />
    </>
  );
};

export default App;

Configuration options for useDwollaWeb

ParameterTypeRequired?Description
environmentstringyesAcceptable values of: sandbox or production
stylesstringnoOptional. A relative or absolute URL linking to a hosted stylesheet containing component styles.
tokenfunctionconditionalA function that gets called by the component for fetching client-tokens as needed throughout the flow.
Example usage: token: (req) => Promise.resolve(dwollaAPIToken(req, {blah: "abcd"}))
Not required if tokenUrl is used.
tokenUrlfunctionconditionalA URL pointing to a server-side endpoint that can be used to generate client-token.
Example usage: tokenUrl: "tokenUrl".
Not required if token is used.
successfunctionnoA function that gets called upon a successful request from the Component.
errorfunctionnoA function that gets called when an error occurs in the Component.

Note: You can use either token or tokenUrl in the config options for generating a client token, but not both. Check out the tokenUrl vs token configuration section in the docs for more information on the differences between the two.

Changelog

  • 1.2.0 Updated Dwolla Web to v3.0.0. Breaking: <DwollaCustomerCreate> with type="receive-only" now requires privacy and terms props (URLs to your Terms of Service and Privacy Policy).
  • 1.1.0 Updated Dwolla Web to v2.2.0, and added new component implementations. See GitHub Releases for more information.
  • 1.0.1 Initial release of React bindings for Dwolla's drop-in components.

Community

Additional Resources

To learn more about Dwolla and how to integrate our product with your application, please consider visiting some of the following resources and becoming a member of our community!

版本与发布记录

@dwolla/react-drop-ins 共发布 4 个版本,首次发布于 2023/03/22;过去 12 个月发布了 1 个版本。

版本发布日期距今
1.2.0latest2026/04/276 个月前
1.1.02023/05/103 年前
1.0.12023/03/223 年前
1.0.02023/03/223 年前

关于 @dwolla/react-drop-ins 的常见问题

@dwolla/react-drop-ins 是什么?

React bindings for Dwolla's drop-in components

如何安装 @dwolla/react-drop-ins?

在项目目录运行 npm install @dwolla/react-drop-ins,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.0.0 || ^19.0.0)、react-dom(^18.0.0 || ^19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@dwolla/react-drop-ins 支持 TypeScript 吗?

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

@dwolla/react-drop-ins 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@dwolla/react-drop-ins 可以商用吗?

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

@dwolla/react-drop-ins 的下载量有多少?

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

@dwolla/react-drop-ins 还在维护吗?

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