Install Reown Appkit
Install Reown Appkit if the desired component you wish to use requires WEB3 wallet connectivity
Install web3 dependencies
Wagmi config setup
Create a new file for your Wagmi configuration.
For this example we will create a file named
config/index.tsx outside our app directory and set up the following configuration.In order for the Wagmi config to work properly you must first setup a
.env file in the root of your directory and create a variable named NEXT_PUBLIC_PROJECT_ID where you will pass in your PROJECT ID. You can create a new PROJECT ID for free by visiting the Reown user dashboard.Context provider setup
Let's create now a context provider that will wrap our application and initialized AppKit (
createAppKit needs to be called inside a Next Client Component file).In this example we will create a file named
context/index.tsx outside our app directory and set up the following configurationLayout setup
Next in our
app/layout.tsx file, we will import our ContextProvider component and call the Wagmi's function cookieToInitialState.The
initialState returned by cookieToInitialState , contains the optimistic values that will populate the Wagmi's store both on the server and client.Extra configuration
Next.js relies on SSR. This means some specific steps are required to make Web3Modal work properly.
Add the following code in the
next.config.mjs file