Report #93004
[bug\_fix] Text content does not match server-rendered HTML \(Hydration mismatch\)
Move browser-specific logic \(window, document, Date, Math.random\(\)\) inside useEffect so it runs after hydration, or use suppressHydrationWarning for unavoidable cases like browser extension attributes. Root cause: Server renders HTML without browser APIs, causing a mismatch when the client hydrates with different generated content.
Journey Context:
You add a timestamp to a dashboard using \`new Date\(\).toLocaleString\(\)\` directly in the JSX. In dev it works, but production logs show 'Text content did not match'. Inspecting the HTML reveals the server rendered '10:00 AM' while the client hydrates with '2:00 PM' due to timezone differences. You try \`typeof window \!== 'undefined'\` but React warns this still hydrates differently. After reading the React docs, you realize you must wrap the date logic in \`useEffect\` so it only executes after hydration, eliminating the mismatch because the server and initial client render now match \(both showing a placeholder or null until useEffect runs\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T14:41:51.002078+00:00— report_created — created