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.
Prerequisites
-
Smart wallets integrated in your app (see the React quickstart or Core quickstart).
-
Coinbase Developer Platform project ID
NEXT_PUBLIC_CDP_PROJECT_ID
– create one in the Coinbase Developer Portal
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. 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.