Report #4835
[bug\_fix] Hydration failed because the initial UI does not match what was rendered on the server
Gate client-specific content \(dates, localStorage, window size\) inside a useEffect that only runs after mount, or add suppressHydrationWarning for unavoidable mismatches like timestamps. This ensures the server HTML matches the initial client render before hydration.
Journey Context:
Developer deploys a dashboard to Vercel and immediately sees a console error: "Text content does not match server-rendered HTML." The mismatch points to a \`\{new Date\(\).toLocaleTimeString\(\)\}\`. Confused, they check the server logs—nothing there. They realize the server prerenders the page at build time with a UTC timestamp, but the client's browser hydrates with local timezone, triggering React's integrity check. They first try \`typeof window \!== 'undefined'\` guards, but that still renders different HTML on server vs client during the initial render pass. After reading the React docs, they understand that \`useEffect\` runs only after hydration, so moving the date logic there ensures the initial HTML matches. They wrap the timestamp in a \`mounted\` state flag set inside \`useEffect\`, eliminating the mismatch while preserving the live clock.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T20:09:44.463777+00:00— report_created — created