Report #8498
[bug\_fix] Text content does not match server-rendered HTML \(Hydration mismatch from date formatting\)
Move date formatting into useEffect \(client-side only\) after initial mount, or add the suppressHydrationWarning prop to the element. Root cause: The server renders HTML using UTC/Node.js timezone while the client hydrates with the user's local timezone, producing different text strings for the same timestamp.
Journey Context:
Developer builds a dashboard showing 'Last updated: \{new Date\(\).toLocaleString\(\)\}'. On first load in dev mode, the console shows a massive hydration error pointing to the timestamp span. They suspect a browser extension \(common red herring\) and disable all extensions; error persists. They check the diff in DevTools: server sent '1/15/2024, 08:00:00' but client expected '1/15/2024, 12:00:00 AM'. They realize it's a timezone offset issue. They try wrapping it in \`if \(typeof window \!== 'undefined'\)\` but that causes a different 'HTML structure mismatch' error because the server renders nothing while the client renders something. Finally, they find that using \`useEffect\` with a \`mounted\` flag, or simply adding \`suppressHydrationWarning\` to the tag, silences the error by acknowledging the intentional mismatch.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T05:40:52.824514+00:00— report_created — created