Skip to content

[BUG] useLocalStorage Hydration Mismatch — Need to setIsClient everywhere #644

@anaclumos

Description

@anaclumos

Describe the bug

In Next.js 15 App Router React Server Components, setting something on the client side (different from the default value) causes a hydration error. Theoretically, I could've useEffect setIsClient(true) everywhere, but that's tedious, and I thought it should be handled at the library level.

To Reproduce

https://stackblitz.com/edit/stackblitz-starters-ty7dbs

Screen.Recording.2024-10-15.at.9.45.24.AM.mov

Expected behavior

It should "re-render" and not cause a hydration error

Additional context

Just started sponsoring you. Great work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions