Onramp Funds to Embedded Smart Wallets with Coinbase
This Recipe demonstrates how to integrate the Coinbase Onramp into an app that uses Alchemy Embedded Smart Wallets. It uses the Coinbase Developer Platform and assumes you’ve configured your smart wallet integration using @account-kit/react
.
Goal: Let users seamlessly buy crypto (e.g. ETH) via card and fund their smart wallet directly.
Framework: This recipe shows a front-end integration in Next.js. The same component can be dropped into any React app.
Heads-up: Coinbase Onramp only works on mainnet. Running this demo will purchase real USDC on Base. Use a payment method you’re comfortable with.
Starting July 31, 2025, all Coinbase Onramp and Offramp URLs must be
securely initialized with the sessionToken
parameter.
Prerequisites
-
Smart wallets integrated in your app (see the React quickstart or Core quickstart).
-
Obtain the necessary API keys all created in the Coinbase Developer Platform
- CDP Project ID
NEXT_PUBLIC_CDP_PROJECT_ID
- CDP API Credentials (used for Secure Initialization with Session Tokens)
CDP_API_KEY
CDP_API_SECRET
- CDP Project ID
Step-by-Step Integration
1. Install Dependencies
2. Create the Onramp Component
This opens a Coinbase-hosted onramp UI in a popup where the user can complete the transaction.
3. Generate Session Token
4. Add to Your App
Best Practices
- Let users change networks/assets in the Coinbase modal (default here is card ➜ ETH).
- For user-level analytics you can pass
partnerUserId
when generating the onramp URL.
Success!
Users can now click “Buy Crypto”, complete their purchase in a popup, and immediately spend the ETH that lands in their smart wallet.
Next Steps
- Sponsor their first transaction – set up Gas Manager so new users don’t pay gas.