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
useRampnowSdkInstallation
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 newRampnowSdk 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 acontainerId.
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 usingsdk.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 usingsdk.send(). This is the reverse direction of events.
Example: Submit a transaction hash from your wallet
When to Use the SDK
SDK vs Widget Mode (URL)
SDK vs Widget Mode (URL)
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
SDK vs Hosted Mode
SDK vs Hosted Mode
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
- View the live demo
- Configure Webhooks for server-side notifications
- Explore Supported Assets
- View API Documentation