Building a Web3 application from scratch often means repeating the same setup over and over again: wallet connection, network handling, providers, UI state, and basic hooks. The Next-Web3-Boilerplate solves this problem by providing a clean, modern starting point for Web3 development using Next.js.
This article explains how the boilerplate works, how to install it, and how to use it as a solid foundation for real Web3 applications. The goal is to stay practical and explicit — no hidden magic, no over‑engineering.
What This Boilerplate Is (and Why It Exists)
The Next-Web3-Boilerplate is designed for developers who want to:
- build dApps with Next.js
- support multiple wallets out of the box
- interact with EVM-compatible blockchains
- avoid writing Web3 setup code from zero every time
It focuses on developer experience, using modern tools that are now considered standard in the Web3 ecosystem.
Tech Stack Overview
This boilerplate is built on top of a well‑known and battle‑tested stack:
- Next.js – React framework for production apps
- TypeScript – type safety and better DX
- Wagmi – React hooks for Ethereum
- Viem – low-level Ethereum client (used internally by Wagmi)
- RainbowKit – wallet connection UI
- Chakra UI – component-based UI system
Each tool has a clear responsibility and integrates cleanly with the others.
What You Get Out of the Box
After installation, the project already includes:
- Wallet connection (MetaMask, WalletConnect, etc.)
- Network selector
- Wallet balance display
- Token balance hooks
- Message signing example
- Light / dark theme support
- Clean project structure
This means you can start building features immediately instead of wiring infrastructure.
Installation
Clone the repository and install dependencies:
git clone https://github.com/truussbeuseqyo/Web3-next-boilerplate-nextjs.git
cd Next-Web3-Boilerplate
npm install
Start the development server:
npm run dev
Your application will be available at:
http://localhost:3000
Environment Variables
Create a .env.local file in the project root.
Example:
NEXT_PUBLIC_PROJECT_NAME=Next Web3 Boilerplate
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=your_walletconnect_project_id
The WalletConnect project ID is required for proper wallet support.
You can create one at:
https://cloud.walletconnect.com/
Wallet Connection (RainbowKit + Wagmi)
Wallet connection is already configured using RainbowKit.
In the UI, users can:
- connect their wallet
- switch networks
- disconnect safely
Example component:
import { ConnectButton } from '@rainbow-me/rainbowkit'
export default function WalletButton() {
return <ConnectButton />
}
No additional logic is required — RainbowKit handles it internally.
Accessing Wallet State
Wagmi exposes simple hooks to access wallet data.
Example: get connected account address.
import { useAccount } from 'wagmi'
const { address, isConnected } = useAccount()
This hook updates automatically when the user connects, disconnects, or switches accounts.
Reading Native Token Balance
To read the wallet balance:
import { useBalance } from 'wagmi'
const { data, isLoading } = useBalance({
address,
})
This works for native tokens (ETH, BNB, etc.) depending on the selected network.
Reading ERC‑20 Token Balance
Reading ERC‑20 balances is also straightforward.
import { useReadContract } from 'wagmi'
const tokenBalance = useReadContract({
address: '0xTokenAddress',
abi: erc20Abi,
functionName: 'balanceOf',
args: [address],
})
No manual provider or signer setup is required.
Signing Messages
Message signing is often required for authentication or off‑chain verification.
import { useSignMessage } from 'wagmi'
const { signMessage } = useSignMessage()
const handleSign = async () => {
await signMessage({ message: 'Sign this message' })
}
This will trigger MetaMask (or another wallet) and return the signature.
Network Handling
The boilerplate already supports network switching.
You can read the current chain like this:
import { useNetwork } from 'wagmi'
const { chain } = useNetwork()
This is useful for:
- validating supported networks
- showing warnings
- adjusting contract addresses dynamically
Project Structure
The project structure is intentionally simple:
src/
├── components/ # UI components
├── hooks/ # Custom Web3 hooks
├── pages/ # Next.js pages
├── providers/ # Wagmi / RainbowKit providers
├── theme/ # Chakra UI theme
└── utils/ # Helper functions
This makes the project easy to scale without refactoring later.
Why This Boilerplate Is a Good Starting Point
This setup is useful because:
- it uses current best practices
- avoids deprecated Web3 libraries
- keeps configuration explicit
- works well for both small and large projects
You can safely build real production features on top of it.
When You Should Use This Boilerplate
This project is a good choice if you want to:
- build a dApp with wallet support quickly
- avoid writing Web3 plumbing code
- focus on product logic instead of setup
- support multiple networks and wallets
If your app is Web3‑centric, this boilerplate saves significant time.
Final Thoughts
The Next-Web3-Boilerplate provides a clean and modern foundation for Web3 applications built with Next.js. It doesn’t try to solve every problem — instead, it solves the right problems and leaves the rest flexible.
Once installed, you can immediately start working on:
- smart contract interactions
- authentication flows
- dashboards
- NFT or token‑based features
All without fighting your setup.
Top comments (0)