@zerohash-sdk/fiat-deposits-react
A React SDK that enables frontend React applications to seamlessly integrate with the Connect Fiat Deposits product.
Connect Fiat Deposits provides a secure, customizable flow for depositing fiat currency directly within your application.
Requirements
- React 18.0.0 or higher
- React DOM 18.0.0 or higher
Installation
npm install @zerohash-sdk/fiat-deposits-react
Getting Started
1. Import the FiatDeposits Component
import { FiatDeposits } from '@zerohash-sdk/fiat-deposits-react';
2. Add the FiatDeposits Component to Your App
function App() {
const jwt = 'your-jwt-token'; // Obtain this from your backend
return (
<FiatDeposits
jwt={jwt}
env="prod" // or "cert" for testing
theme="auto" // 'auto' (default), 'light', or 'dark'
/>
);
}
3. Configure Event Callbacks (Optional)
function App() {
const jwt = 'your-jwt-token';
return (
<FiatDeposits
jwt={jwt}
env="prod"
theme="auto"
onCompleted={({ amountDeposited, assetSymbol }) => {
console.log('Deposit completed:', amountDeposited, assetSymbol);
}}
onError={({ errorCode, reason }) => {
console.log('Error:', errorCode, 'Reason:', reason);
}}
onClose={() => console.log('Widget closed')}
onEvent={({ type, data }) => console.log('Event:', type, data)}
onLoaded={() => console.log('Widget loaded and ready')}
/>
);
}
Complete Example
import { FiatDeposits } from '@zerohash-sdk/fiat-deposits-react';
import React from 'react';
function App() {
const jwt = 'your-jwt-token';
return (
<div className="App">
<h1>My App</h1>
<FiatDeposits
jwt={jwt}
env="prod"
theme="auto"
onCompleted={({ amountDeposited, assetSymbol }) => {
console.log('Deposited:', amountDeposited, assetSymbol);
}}
onError={({ errorCode, reason }) => console.log('Error:', errorCode, reason)}
onClose={() => console.log('Widget closed')}
onEvent={({ type, data }) => console.log('Event type:', type, 'Event data:', data)}
onLoaded={() => console.log('Widget loaded and ready')}
/>
</div>
);
}
export default App;
API Reference
FiatDeposits Component Props
| 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 |
({ amountDeposited, assetSymbol }) => void |
No |
- |
Callback when the deposit flow 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 |
More Information & Support
For comprehensive documentation or support about Connect, visit our Documentation Page.