This guide demonstrates how to add embedded wallets to your existing React app with just a few lines of code.
Check out the CDP Web SDK reference for comprehensive method signatures, types, and examples.
Already have user authentication? If you’re using Auth0, Firebase, AWS Cognito, or another identity provider, check out Custom Authentication to integrate with your existing auth system.
What is an embedded wallet?
An embedded wallet is a self-custodial crypto wallet built directly into your app. Unlike traditional wallets (like MetaMask) that require browser extensions and seed phrases, embedded wallets let users sign in with familiar auth methods such as email, mobile SMS, and OAuth while maintaining full control of their assets.Key benefits:
No downloads: Works instantly in any browser
Email sign-in: No seed phrases to manage, but users retain full control
You control the UX: Seamlessly integrated into your app
A node package manager installed (i.e., npm, pnpm, or yarn)
Basic familiarity with React and TypeScript
Configured your domain in CDP Portal (see below)
How to configure your domain in CDP Portal
Step 1: Access CDP PortalNavigate to the Domains Configuration in CDP Portal, and click Add domain to include your local app.
Step 2: Add your domain
For local development: Use http://localhost:3000 (or your preferred port)
For production: Use your actual domain (e.g., https://yourapp.com)
For production apps, only add your actual production domain. Do not add localhost to production CDP projects as malicious apps running locally could impersonate your frontend and abuse your project credentials.
Step 3: Save your changesClick Add domain again to save your changes.
You should see your domain listed in the CDP Portal dashboard. The allowlist will take effect immediately upon saving.
TypeScript users: Set moduleResolution: "node16" or "nodenext" in your tsconfig.json (not the legacy "node") to avoid compilation errors with the CDP SDK.
Add the CDP provider to your root component (typically App.tsx or main.tsx). Replace "your-project-id" with your actual project ID from CDP Portal.
Report incorrect code
Copy
Ask AI
import { CDPReactProvider } from "@coinbase/cdp-react";function App() { return ( <CDPReactProvider config={{ projectId: "your-project-id", ethereum: { // if you want to create an EVM account on login createOnLogin: "eoa" // or "smart" for smart accounts }, solana: { // if you want to create a Solana account on login createOnLogin: true }, appName: "Your App Name" }} > <YourExistingApp /> </CDPReactProvider> );}