RainbowKit is a React library that makes it easy to add wallet sign-in to your onchain application. It’s designed to work out-of-the-box and includes native support for Base Account.By integrating RainbowKit with Base Account, you can provide your users with a seamless onboarding experience while maintaining access to the full Base Account feature set.
Access the latest version of the Base Account SDK (Recommended)It is to access the latest version of the Base Account SDK in order to get the latest features and bug fixes.To do this, you can use the following command to override it:
npm pkg set overrides.@base-org/account="latest"# OR manually add to package.json:# "overrides": { "@base-org/account": "latest" }
Or you can use a specific version by adding the version to the overrides:
npm pkg set overrides.@base-org/account="2.2.0"# OR manually add to package.json:# "overrides": { "@base-org/account": "2.2.0" }
Make sure to delete your node_modules and package-lock.json and run a new install to ensure the overrides are applied.
Create a wagmi.ts file in your src directory to configure your blockchain connections and wallet options:
src/wagmi.ts
import { getDefaultConfig } from '@rainbow-me/rainbowkit';import { base, mainnet} from 'wagmi/chains';export const config = getDefaultConfig({ appName: 'My Base Account App', projectId: 'YOUR_PROJECT_ID', // Replace with your Reown project ID chains: [ mainnet, base ], ssr: true, // Enable server-side rendering support});
Replace YOUR_PROJECT_IDMake sure to replace 'YOUR_PROJECT_ID' with the actual project ID you obtained from Reown Cloud.For production applications, use environment variables:
The ConnectButton is RainbowKit’s all-in-one wallet connection component. It displays the wallet connection modal with all available wallets, including Base Account.
The WalletButton component provides a direct connection to a specific wallet. This is ideal when you want to highlight Base Account as the primary wallet option.