Report #79764
[bug\_fix] Text content does not match server-rendered HTML \(hydration mismatch\)
Add suppressHydrationWarning to the element or move client-dependent values \(Date.now, Math.random, window dimensions\) inside useEffect so the server renders a placeholder and the client patches it after mount. Root cause: Server renders HTML in Node.js without browser state \(timezone, screen size, browser extensions\), but React expects the initial client render to match exactly.
Journey Context:
Developer deploys a Next.js app and sees a console error about text mismatch. The diff shows the server sent '169999999' but the client expected '170000000' \(a timestamp\). Developer checks the component—it's using Date.now\(\) directly in the render. They try wrapping it in typeof window \!== 'undefined', but the error persists because the import is still evaluated during SSR. They search the Next.js docs and find suppressHydrationWarning, which silences the error but feels wrong. Eventually, they move the timestamp logic into useEffect with an empty dependency array, ensuring the server renders a static placeholder \(like null or a skeleton\) and the client updates it after hydration, matching React's expectations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T16:28:50.451438+00:00— report_created — created