wevm / wagmi

React Hooks for Ethereum

Home Page:https://wagmi.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When enabling SSR property with cookie storage, NextJS changes all routes to SSR

Maxservais opened this issue · comments

Describe the bug

I'm currently developing a Next.js v14 project that utilizes the App router to statically generate a significant number of pages, including blog articles, at build time.

I'm trying to integrate Wagmi along with Web3Modal into my app. However, following the guidelines provided in the Wagmi documentation, I encountered an issue. Specifically, when I enable the ssr property within the Wagmi Config, proceed to establish cookie storage, and then hydrate the cookies as instructed, I've observed that all my Next.js application's routes inadvertently switch to being server-side rendered (SSR) pages.

Has anyone found a workaround?

Link to Minimal Reproducible Example

No response

Steps To Reproduce

  1. Set up a nextjs project with at least one static page (prerendered as static content)
  2. Set up wagmi and follow the steps here to set up wagmi properly with SRR.
  3. The page that was static is now dynamic (server-rendered on demand using Node.js) because of initialState being passed to the component

export default function Layout({ children }: { children: ReactNode }) { const initialState = cookieToInitialState( config, headers().get('cookie') ) return ( <html lang="en"> <body> <Providers initialState={initialState}> {children} </Providers> </body> </html> ) }

Wagmi Version

Latest

Viem Version

Latest

TypeScript Version

5.1.3

Check existing issues

Anything else?

No response

This issue has been locked since it has been closed for more than 14 days.

If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest wagmi version. If you have any other comments you can create a new discussion.