Report #61888
[bug\_fix] Hydration mismatch caused by Date, Math.random, or window check during SSR
Move non-deterministic values or browser API access into useEffect \(client-side only\), or add suppressHydrationWarning=\{true\} to the element when mismatch is unavoidable \(e.g., browser extensions\). Root cause: Server and client generate different initial HTML, breaking React's checksum validation.
Journey Context:
Developer builds a dashboard showing 'Last updated: \{new Date\(\).toLocaleString\(\)\}' directly in the JSX. In development \(client-side only\), it works. On Vercel production build, console shows 'Text content did not match: Server: "Jan 1, 2024" Client: "Jan 2, 2024"' \(timezone drift\). Developer tries to guard with typeof window \!== 'undefined' but learns that during SSR, window is indeed undefined on both sides, so the server still renders something different. Debugging leads to realizing that any value that differs between server/client must be generated inside useEffect \(which only runs client-side\) or suppressed.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T10:22:00.415975+00:00— report_created — created