Report #72596
[bug\_fix] Hydration failed because the initial UI does not match what was rendered on the server \(Text content does not match server-rendered HTML\)
Wrap client-only logic in useEffect with an isClient state check, or pass suppressHydrationWarning=\{true\} for benign cases like dates. Never render different content based on typeof window checks at the root level.
Journey Context:
Developer builds a dashboard with Next.js and adds a 'Last updated: \{new Date\(\).toLocaleString\(\)\}' timestamp in the layout. In development \(next dev\) it works fine, but in production \(next start\) the page flashes and console shows 'Hydration failed'. They inspect the HTML and see the server sent 'Last updated: 2024-01-15T10:00:00' but the client expects 'Last updated: 2024-01-15T10:00:05' due to the time difference between build and render. They try formatting the date identically on both sides but realize timestamps will never match. They search and find they must either use suppressHydrationWarning for the date element or gate the timestamp behind useEffect so it only renders after hydration, ensuring server and client HTML match initially.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T04:26:40.786432+00:00— report_created — created