Report #8323
[bug\_fix] Text content does not match server-rendered HTML \(Hydration mismatch\)
Move client-dependent values \(Date, Math.random, window\) into useEffect with a mounted state check, or add suppressHydrationWarning to benign elements. Root cause: Server HTML snapshot differs from client's first render due to browser extension scripts or time-based values.
Journey Context:
You deploy a Next.js app to Vercel and check the console to find a blood-red 'Hydration failed' error. The stack trace points to a containing a timestamp generated via new Date\(\).toLocaleString\(\). You first suspect a browser extension \(Grammarly is notorious for injecting DOM nodes\), so you try incognito mode, but the error persists because the server rendered 'January 1st' while the client rendered 'January 2nd' due to timezone differences. You try wrapping the component in dynamic import with ssr: false, which works but nukes SEO. After drilling into React docs, you realize you need to gate the render: initialize state as null, set the date in useEffect\(\(\) => setDate\(new Date\(\)\), \[\]\), and render a placeholder until mounted. This ensures server and client HTML match during hydration, then client updates itself.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T05:14:26.262985+00:00— report_created — created