Recommended: JavaScript SDK with React Hooks
For new React apps, we recommend the JavaScript SDK with React Hooks (
@dynamic-labs-sdk/react-hooks) instead of the legacy React SDK documented here. The JS SDK comes with many benefits such as a much smaller bundle size and other optimizations. Use the React quickstart (JavaScript SDK) to get started.This guide is currently React only.
Setup Instructions
1
Create Dynamic Environment
- Visit the Dynamic Dashboard
- Create a new app or select an existing one
- Enable the
Embedded Walletsfeature - Copy your Environment ID from the dashboard
2
Get Gelato API Key
- Visit the Gelato App
- Navigate to
Paymaster & Bundler > API Keys - Create a new API Key and select your required networks
- Copy the generated API Key
3
Create app with the React Quickstart
Scaffold Next.js with
create-next-app, then follow the React Quickstart Custom setup path: Ethereum (EVM) with Wagmi and viem. In the Dynamic dashboard, enable Embedded wallets and Ethereum under Chains & Networks, and add your dev origin under Security → Allowed Origins.4
Install Gelato Smart Wallet SDK
From your project root, install the Gelato Smart Wallet SDK:
5
Set Environment Variables
In the scaffolded project, create a
.env.local file in the project root:Implementation
1
Configure providers (lib/providers.tsx)
In the scaffolded app, update your providers to include Dynamic, Wagmi, and React Query. If your project already has a
lib/providers.tsx, edit it; otherwise create it and use it in your root layout.2
Create Smart Wallet Client (components/SendTransactionButton.tsx)
3
Use the button (e.g., app/page.tsx)
4
Execute Transactions
Execute transactions using different payment methods:
- Sponsored
- ERC-20
- Native