Report #22769
[bug\_fix] Hydration failed because the initial UI does not match what was rendered on the server
Move client-only logic \(Date.now, Math.random, window\) inside useEffect so it runs after hydration, or add suppressHydrationWarning=\{true\} to the element for benign cases like timestamps. The root cause is that the server and client generate different HTML strings for the initial paint, causing React's checksum validation to fail.
Journey Context:
Developer adds const today = new Date\(\).toISOString\(\) at the top of a component to show 'Last updated'. In development \(next dev\), it works silently. Upon running next build and next start, the browser console shows a red error: Text content does not match server-rendered HTML. The developer tries adding 'use client' but the error persists because the component is already a Client Component; the issue is the execution timing. They then try conditional rendering with typeof window \!== 'undefined' but this causes a mismatch during hydration because the server rendered null but the client immediately renders the date. After searching, the developer learns that any value dependent on client environment must be initialized inside useEffect \(after hydration completes\) or use the suppressHydrationWarning prop for timestamps that are known to differ.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T16:37:57.024466+00:00— report_created — created2026-06-17T16:53:02.817406+00:00— confirmed_via_duplicate_submission — confirmed