Skip to main content
The @zbdpay/ramp-react package is a React wrapper for the ZBD Ramp widget that enables Buying Bitcoin with USD directly to the Lightning Network.

Features

  • React Optimized: Built specifically for React with hooks and components
  • TypeScript Support: Full type safety with comprehensive TypeScript definitions
  • Ref API: Access to underlying ramp instance methods via React refs
  • Hook Support: useZBDRamp hook for programmatic usage
  • Session Token Based: Uses secure session tokens for authentication

Installation

Quick Start

1. Create Session Token

First, create a session token using the ZBD API:

2. Use ZBDRamp Component

API Reference

initRampSession

Creates a new session token for the ZBD Ramp widget.
InitRampSessionConfig
required
Configuration object for creating a session

Configuration Parameters

string
required
Your ZBD API key
string
required
User’s email address
string
required
Lightning address or Bitcoin address
QuoteCurrencyEnum
required
Quote currency (e.g., USD)
BaseCurrencyEnum
required
Base currency (e.g., BTC)
string
Webhook URL for notifications
string
Your internal reference ID
Record<string, any>
Additional metadata to attach to the session

ZBDRamp Component

React component that renders the ZBD Ramp widget.

Props

string
required
Session token from ZBD API
string | number
default:"100%"
Widget width
string | number
default:"600px"
Widget height (minimum 600px recommended)
string
CSS class for container
React.CSSProperties
Inline styles for container

Callback Props

(data: any) => void
Called when payment is successful
(error: RampError) => void
Called when an error occurs
(step: string) => void
Called when user navigates to a different step
(log: RampLog) => void
Debug/info logging callback
() => void
Called when widget is fully loaded
() => void
Called when user closes the widget

Ref API

useZBDRamp Hook

Hook for creating and managing ZBD Ramp instances programmatically.

Usage Examples

Basic Component

With Ref for Control

Using the Hook

Error Handling

Session Token Creation

TypeScript Support

The package includes comprehensive TypeScript definitions:

Type Examples

Complete Example App

The repository includes a complete example application:
The example includes:
  • Session token creation form
  • Complete ZBD Ramp integration
  • Error handling and callbacks
  • TypeScript implementation

TypeScript

Core TypeScript/JavaScript SDK

React Native

React Native components

Flutter

Flutter plugin

Resources

Support

For support and questions: