$ Web3 Wallet Connection: The 2025 Stack
WalletConnect v2, RainbowKit, wagmi, viem — the modern wallet stack is great, but only if you wire it up in the right order. A pragmatic guide.
The Web3 frontend stack consolidated in 2024. If you're starting a new dApp in 2025, the answer is almost always:
- viem — the typed Ethereum client (replaces ethers.js)
- wagmi — React hooks built on viem
- RainbowKit — the wallet UI
- WalletConnect v2 — the multi-wallet protocol underneath
The 5-minute setup
npm i wagmi viem @rainbow-me/rainbowkit @tanstack/react-queryWrap your app in WagmiProvider > QueryClientProvider > RainbowKitProvider (in that order — order matters), drop a <ConnectButton />, and you have wallet connection in 12 lines.
The gotchas
SSR. Wagmi reads window at import time in some paths. Lazy-load the provider on the client only, or use the ssr: true wagmi config and persist via cookies.
Chain mismatch. Always show the user what chain you expect. useSwitchChain + a banner beats silent failures.
Read vs write. useReadContract works without a connected wallet. useWriteContract needs one and a chain match. Don't conflate the loading states.