Report #3798
[bug\_fix] Hydration failed because the initial UI does not match server-rendered HTML \(Text content does not match\)
Move dynamic values \(new Date\(\), Math.random\(\), window/localStorage\) into a useEffect hook with an isClient guard, or add suppressHydrationWarning=\{true\} to the element if the mismatch is benign \(e.g., browser extension injected attributes\). Root cause: Server renders with initial state; client expects identical HTML for hydration, but Date locale or random values differ between environments.
Journey Context:
You add a timestamp to your footer using \{new Date\(\).toLocaleDateString\(\)\}. It works in dev, but in production \(next start\) the console shows a violent red error about hydration mismatch. You suspect a Chrome extension, so you open an incognito window—same error. You start binary-search commenting out components. The error vanishes when you remove the date. You realize the server rendered '1/15/2024' but your client, set to UK locale, rendered '15/01/2024'. You wrap the date in useEffect with a mounted flag so it only renders client-side after hydration, and the error disappears because the server and initial client HTML now match.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T18:14:04.171343+00:00— report_created — created