Web Sdk
Onramp Web SDK
A TypeScript/JavaScript SDK for integrating Onramp's crypto purchase widget into your web application.
Installation
Install the SDK using npm:
npm install @onramp.money/onramp-web-sdkOr using yarn:
yarn add @onramp.money/onramp-web-sdkQuick Start
1. Import the SDK
ES6/TypeScript:
import { OnrampWebSDK } from '@onramp.money/onramp-web-sdk';CommonJS:
const { OnrampWebSDK } = require('@onramp.money/onramp-web-sdk');Browser (UMD):
<script src="node_modules/@onramp.money/onramp-web-sdk/dist/onramp-web-sdk.umd.js"></script>2. Initialize the SDK
3. Show the Widget
4. Handle Events (Optional)
5. Close the Widget
Usage Examples
Basic Overlay Mode
Embedded Mode
Custom Theming
widgetUrl
You can pass the kycUrl you get from our api into the sdk to initialise it as a kyc sdk
Configuration Options
appId
number
✅
Your application ID from Onramp dashboard
walletAddress
string
❌
User's wallet address
coinCode
string
❌
Cryptocurrency code (e.g., "USDT", "ETH")
network
string
❌
Blockchain network (e.g., "polygon", "ethereum")
fiatAmount
number
❌
Pre-filled fiat amount
coinAmount
number
❌
Pre-filled crypto amount
paymentMethod
number
❌
Preferred payment method ID
flowType
number
❌
1: Buy, 2: Sell, 3: Checkout, 4: Swap
containerId
string
❌
DOM element ID for embedded mode (e.g., "#container")
theme
object
❌
Custom theme configuration
sandbox
boolean
❌
Use sandbox environment for testing
lang
string
❌
Language code (e.g., "en", "es")
phoneNumber
string
❌
Pre-filled phone number
redirectUrl
string
❌
Redirect URL after completion
widgetUrl
string
❌
Kyc url containing kybData
Flow Types
1 (Buy/Onramp): Purchase cryptocurrency with fiat
2 (Sell/Offramp): Sell cryptocurrency for fiat
3 (Checkout): NFT/asset purchase flow
4 (Swap): Cryptocurrency swap
Event Types
Transaction Events (TX_EVENTS)
ONRAMP_WIDGET_TX_INITONRAMP_WIDGET_TX_FINDINGONRAMP_WIDGET_TX_SELLINGONRAMP_WIDGET_TX_PURCHASINGONRAMP_WIDGET_TX_SENDINGONRAMP_WIDGET_TX_SENTONRAMP_WIDGET_TX_COMPLETED
Widget Events (WIDGET_EVENTS)
ONRAMP_WIDGET_READYONRAMP_WIDGET_CLOSE_REQUEST_CONFIRMEDONRAMP_WIDGET_FAILEDONRAMP_WIDGET_CONTENT_COPIEDONRAMP_WIDGET_LOGIN_SUCCESSONRAMP_WIDGET_NAVIGATION
KYC Events (KYC_EVENTS)
ONRAMP_KYC_READYONRAMP_KYC_PENDINGONRAMP_KYC_ERRORONRAMP_KYC_REJECTEDONRAMP_KYC_CLOSE
Methods
show()
Displays the Onramp widget.
close()
Closes the Onramp widget.
on(eventType, callback)
Registers event listeners.
Error Handling
Complete Example
Support
For questions and support:
Documentation: https://docs.onramp.money
Email: support@onramp.money
Website: https://onramp.money
Last updated