Skip to main content
The Rampnow SDK provides a developer-friendly wrapper around the widget integration, with full TypeScript support, event handling, and a React hook.

Overview

The @rampnow/sdk package lets you embed Rampnow’s onramp/offramp widget into your application with just a few lines of code. It supports three integration modes and ships with TypeScript definitions out of the box.

Overlay Mode

Full-screen modal overlay — quickest setup, no container needed

Embedded Mode

Mount the widget inside any DOM element in your layout

Redirect Mode

Generate a URL to open in a new tab — ideal for native apps or email links

React Hook

First-class React support via useRampnowSdk
Try the SDK live at demo.rampnow.io.

Installation

CDN (no bundler):
When loaded via CDN, the SDK is available as window.RampnowSdk.

Quick Start

1

Get your API key

Obtain your public API key from the Rampnow Partner Dashboard under API Hub. Keys are prefixed with pk_live_....
2

Initialize the SDK

3

Open the widget

4

Listen for events


Configuration

Pass a config object when creating a new RampnowSdk instance:

Integration Modes

Overlay Mode (Default)

Opens the widget as a full-screen modal overlay. No container element needed.

Embedded Mode

Mount the widget inside a specific DOM element by providing a containerId.

Redirect Mode

Generate a widget URL without opening an iframe — useful for native apps, email links, or server-side flows.

React Integration

The SDK ships with a React hook for seamless integration in React applications.
React (>=18) and ReactDOM (>=18) are optional peer dependencies — only required when using the hook.

API Reference

new RampnowSdk(config)

Creates an SDK instance. Validates the apiKey and merges defaults. Does not open the widget — call .init() to display it.

sdk.init(): RampnowSdk

Opens the widget. If containerId is set, mounts the iframe in that element; otherwise creates a full-screen overlay. Returns this for chaining.

sdk.close(): void

Closes and removes the widget from the DOM.

sdk.on(eventType, callback): RampnowSdk

Subscribe to widget events. Returns this for chaining.

sdk.off(eventType, callback): RampnowSdk

Unsubscribe from events. Same forms as .on().

sdk.send(commandType, payload): RampnowSdk

Send a command to the widget iframe. Returns this for chaining. See Commands for available command types.

sdk.isOpen: boolean

Read-only property indicating whether the widget is currently displayed.

RampnowSdk.createRedirectUrl(config): string (static)

Builds a full widget URL from config without opening any iframe. Returns a URL string.

Events

Subscribe to events using sdk.on() with the RampnowEventType enum:

CryptoTxnInfo

Available in ORDER_CREATED and ORDER_COMPLETED event payloads:

Example: Full Event Handling


Commands

Commands are messages sent from the SDK to the widget using sdk.send(). This is the reverse direction of events.
Domain whitelisting required: For security, the widget only accepts commands from whitelisted origins. To whitelist your domain, please contact Rampnow. Commands sent from non-whitelisted origins will be silently ignored.

Example: Submit a transaction hash from your wallet


When to Use the SDK

The SDK wraps the widget mode integration with a programmatic API. Use the SDK when you need:
  • Event-driven callbacks (order status updates)
  • Programmatic control (open/close the widget)
  • React integration via hooks
  • Type-safe configuration with TypeScript
Use Widget Mode directly when you only need a simple iframe or redirect.
Use the SDK for a drop-in widget experience. Use Hosted Mode when you need full control over the UI and want to build a custom flow using the REST APIs directly.

Next Steps