You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Open browser dev tools and set a cookie myCookie with e.g. a value of value to cookie storage
Fully reload the page
Observe browser JS console output
Describe the Bug
JS console contains a hydration error:
Warning: Text content did not match. Server: "" Client: "value"
p
[...]
Expected Behavior
Client components that use useState() should not cause hydration errors due to server client content mismatch as by definition their content can only be fully rendered on the client.
Client components are still server-side rendered, they're equivalent to the components you write in pages today. The only new part is server components which only render on the server.
As such you can still create hydration mismatches based on reading values only available in the browser, those should be read in useEffect.
From looking at the code you're using you should be able to use the new cookies() function in server components for the use-case.
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true)
Link to the code that reproduces this issue
https://github.com/advancingu/nextjs-13.2-hydration-repro
To Reproduce
npm i
npm run dev
myCookie
with e.g. a value ofvalue
to cookie storageDescribe the Bug
JS console contains a hydration error:
Expected Behavior
Client components that use
useState()
should not cause hydration errors due to server client content mismatch as by definition their content can only be fully rendered on the client.Possibly related to #45246
Which browser are you using? (if relevant)
Firefox 110
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered: