Skip to main content
The @zbdpay/ramp-ts package is the core TypeScript/JavaScript iframe wrapper for the ZBD Ramp widget that enables Bitcoin purchase interface for web applications.

Features

  • TypeScript First: Full type safety with comprehensive TypeScript definitions
  • PostMessage Communication: Real-time error handling, logging, and step tracking
  • Lightweight: No dependencies, tree-shakeable
  • Framework Agnostic: Works with any JavaScript framework or vanilla JS

Installation

Quick Start

1. Create Session Token

First, create a session token using the ZBD API:

2. Create and Mount Widget

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

Response

Example

createRamp

Creates a new ZBD Ramp widget instance.
RampOptions
required
Configuration options for the widget

Options

string
required
Session token from initRampSession
HTMLElement | string
Container element or CSS selector
string | number
default:"100%"
Widget width
string | number
default:"100%"
Widget height (minimum 600px recommended)

Callback Options

(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

Returns

Usage Examples

Basic Implementation

With Event Handlers

Custom Dimensions

Programmatic Control

Error Handling

TypeScript Support

The package includes comprehensive TypeScript definitions:

Type Examples

Simple Iframe Alternative

If you don’t need JavaScript callbacks, you can use a simple iframe:

Framework Integrations

This is the core package. For framework-specific integrations, see:

React

React components and hooks

React Native

React Native components

Flutter

Flutter plugin

Try It Out

Interactive Example

To try the interactive example locally:
  1. Clone the repository:
  2. Start a local server:
  3. Fill the form with your API key and user details
  4. Click “Create Session & Load Ramp” to see it in action

CodeSandbox Example

Try it online: CodeSandbox Demo

Resources

Support

For support and questions: