Skip to content

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

@Maxservais

Description

@Maxservais

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions