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.
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 QuickstartCustom 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:
npm install @gelatonetwork/smartwallet
5
Set Environment Variables
In the scaffolded project, create a .env.local file in the project root:
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.
// lib/providers.tsximport React from "react";import { DynamicContextProvider } from "@dynamic-labs/sdk-react-core";import { EthereumWalletConnectors, isEthereumWallet } from "@dynamic-labs/ethereum";import { DynamicWagmiConnector } from "@dynamic-labs/wagmi-connector";import { QueryClientProvider, QueryClient } from "@tanstack/react-query";import { WagmiProvider, createConfig, http } from "wagmi";import { baseSepolia } from "viem/chains";const queryClient = new QueryClient();export default function Providers({ children }: { children: React.ReactNode }) { return ( <DynamicContextProvider settings={{ environmentId: process.env.NEXT_PUBLIC_DYNAMIC_APP_ID!, walletConnectors: [EthereumWalletConnectors], }} > <WagmiProvider config={createConfig({ chains: [baseSepolia], transports: { [baseSepolia.id]: http(), }, })} > <QueryClientProvider client={queryClient}> <DynamicWagmiConnector>{children}</DynamicWagmiConnector> </QueryClientProvider> </WagmiProvider> </DynamicContextProvider> );}