Report #48038
[bug\_fix] Hydration failed because the initial UI does not match what was rendered on the server
Ensure deterministic rendering between server and client by avoiding Date.now\(\), Math.random\(\), or localStorage access during the initial render. Use useEffect to gate client-only content, or add the suppressHydrationWarning prop to the element if the content difference is expected and benign.
Journey Context:
Developer adds a timestamp to the UI using new Date\(\).toLocaleString\(\) to show 'last updated'. In development with Fast Refresh, everything works. After deployment, the browser console shows a red error: 'Hydration failed because the initial UI does not match...'. The developer inspects the HTML and sees the server-rendered timestamp differs from the client-side React tree. Attempting to fix it with suppressHydrationWarning silences the error but the timestamp is still wrong on SSR. The developer eventually moves the date formatting into a useEffect hook with an isClient state flag, rendering a placeholder on the server and the real date only after client hydration completes.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T11:06:56.622367+00:00— report_created — created