https://github.com/dwolla/react-drop-ins
React component wrappers for use with Dwolla's drop-ins library
https://github.com/dwolla/react-drop-ins
components drop-in dwolla react
Last synced: about 2 months ago
JSON representation
React component wrappers for use with Dwolla's drop-ins library
- Host: GitHub
- URL: https://github.com/dwolla/react-drop-ins
- Owner: Dwolla
- License: mit
- Created: 2023-01-18T22:42:41.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-11T16:09:35.000Z (almost 2 years ago)
- Last Synced: 2025-04-10T06:43:33.646Z (about 2 months ago)
- Topics: components, drop-in, dwolla, react
- Language: TypeScript
- Homepage: https://dwolla.github.io/react-drop-ins/
- Size: 2.04 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-drop-ins [](https://badge.fury.io/js/@dwolla%2Freact-drop-ins)
React bindings for Dwolla's [drop-in components](https://developers.dwolla.com/concepts/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](#installation)
* [Examples](#examples)
* [Storybook](#storybook)
* [Usage](#usage)
* [Changelog](#changelog)
* [Community](#community)
* [Additional Resources](#additional-resources)## Installation
```shell
# 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](https://github.com/Dwolla/react-drop-ins/tree/main/src/examples) directory.
### [Storybook](https://dwolla.github.io/react-drop-ins/)
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](https://developers.dwolla.com/sdks-tools) 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](https://developers.dwolla.com/guides/drop-ins/generate-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](#configuration-options-for-usedwollaweb) below._
```typescript
// 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) returnLoading...;// Handle errors
if (error) returnError;// Render the DwollaCustomerCreate component when ready
return (
<>
>
);
};export default App;
```### Configuration options for `useDwollaWeb`
| Parameter | Type | Required? | Description |
| ----------- | -------- | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| environment | string | yes | Acceptable values of: `sandbox` or `production` |
| styles | string | no | Optional. A relative or absolute URL linking to a hosted stylesheet containing component styles. |
| token | function | conditional | A 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. |
| tokenUrl | function | conditional | A 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. |
| success | function | no | A function that gets called upon a successful request from the Component. |
| error | function | no | A 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](https://developers.dwolla.com/guides/drop-ins/generate-client-token#token-url-vs-token-configuration) section in the docs for more information on the differences between the two.
## Changelog
- **[1.1.0](https://github.com/Dwolla/react-drop-ins/releases/tag/v1.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
* If you have any feedback, please reach out to us on [our forums](https://discuss.dwolla.com/) or by [creating a GitHub issue](https://github.com/Dwolla/react-drop-ins/issues).
* If you would like to contribute to this library, [bug reports](https://github.com/Dwolla/react-drop-ins/issues) and [pull requests](https://github.com/Dwolla/react-drop-ins/pulls) are always appreciated!## 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](https://www.dwolla.com/)
* [Dwolla Developers](https://developers.dwolla.com/)
* [Developer Support Forum](https://discuss.dwolla.com/)