Installation
Get up and running with RainbowKit
You can scaffold a new RainbowKit + wagmi + Next.js app with one of the following commands, using your package manager of choice:
This will prompt you for a project name, generate a new directory containing a boilerplate project, and install all required dependencies.
Alternatively, you can manually integrate RainbowKit into your existing project.
Install RainbowKit and its peer dependencies, wagmi, viem, and @tanstack/react-query.
Import RainbowKit, Wagmi and TanStack Query.
Configure your desired chains and generate the required connectors. You will also need to setup a wagmi
config. If your dApp uses server side rendering (SSR) make sure to set ssr
to true
.
Wrap your application with RainbowKitProvider
, WagmiProvider
, and QueryClientProvider
.
Then, in your app, import and render the ConnectButton
component.
RainbowKit will now handle your user's wallet selection, display wallet/transaction information and handle network/wallet switching.
Some build tools will require additional setup.
The Webpack v5 bundler used by Next.js and Create React App no longer provides Node polyfills, so you'll need to include these modules yourself to satisfy RainbowKit's peer dependencies. Create React App specifically requires that you polyfill Buffer
.
Reference our Next.js Webpack Config, Next.js App Router Webpack Config, and Create React App polyfills samples for configuration guidance for your project.
The Vite bundler doesn't provide Node polyfills, so you'll need to include polyfills for global
, Buffer
and process.env
. As an example, you can reference the polyfills in our sample Vite project.
When using Remix, you must polyfill buffer
, events
and http
modules. Reference the Remix configuration below, or our sample Remix project.
By default, your dApp uses public RPC providers for each chain to fetch balances, resolve ENS names, and more. This can often cause reliability issues for your users as public nodes are rate-limited. You should instead purchase access to an RPC provider through services like Alchemy or QuickNode, and define your own Transports in Wagmi. This can be achieved by adding the transports
param in getDefaultConfig
or via Wagmi's createConfig
directly.
A Transport is the networking middle layer that handles sending JSON-RPC requests to the Ethereum Node Provider (like Alchemy, Infura, etc).
Example with an http
transport
For more details, view the wagmi transport docs.
Now that your users can connect their wallets, you can start building out the rest of your app using wagmi.
Send transactions, interact with contracts, resolve ENS details and much more with wagmi’s comprehensive suite of React Hooks.
For more detail, view the wagmi documentation.
To see some running examples of RainbowKit, or even use them to automatically scaffold a new project, check out the official examples.
To try RainbowKit directly in your browser, check out the CodeSandbox links below:
- with Create React App
- with Next.js
- with Next.js App Router
- with Remix
- with Vite