Report #100543
[bug\_fix] Hydration failed because the server rendered HTML didn't match the client; console shows "Text content does not match server-rendered HTML" or a diff of mismatched nodes.
Make the initial server and client renders produce identical markup. Move client-only values \(Date.now, Math.random, locale-dependent formatting, localStorage, window\) out of the first render: render a stable placeholder on the server and update it inside useEffect. For an unavoidable single-element mismatch such as a timestamp, add suppressHydrationWarning=\{true\} to that element, but do not use it to hide real bugs.
Journey Context:
I added \{new Date\(\).toLocaleDateString\(\)\} to a Next.js page and the dev server looked fine, but the production build logged a hydration mismatch. I first tried suppressHydrationWarning everywhere, which only hid the symptom. After reading the hydrateRoot docs I realized React re-executes the component tree on the client and compares it to the server HTML; any difference breaks hydration because React needs the same DOM node map on both sides. I switched to a two-pass render: a useEffect sets isClient to true after hydration, and only then do I show the locale-aware date. The mismatch disappeared because the first render now matches the server output exactly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-02T04:41:11.186235+00:00— report_created — created