Report #4152
[bug\_fix] Text content does not match server-rendered HTML \(Hydration Error\)
Move client-only logic \(accessing window, localStorage, Date.now, Math.random\) inside a useEffect hook so it only runs after hydration, or add the \`suppressHydrationWarning\` prop to the element if the mismatch is unavoidable \(e.g., from browser extensions\).
Journey Context:
Developer adds a timestamp or uses \`window.localStorage\` directly in a component's render body. In development, it works fine or shows a brief mismatch warning. After building for production \(\`next build\`\), the server renders a different string \(e.g., SSR timestamp\) than what the client hydrates \(browser timestamp\), triggering a hard hydration error that can crash the page. Developer suspects browser extensions, adds \`suppressHydrationWarning\`, but the real issue is the non-deterministic render path. Moving the logic into \`useEffect\` \(which only runs client-side post-hydration\) ensures the server and client HTML match during the initial render, resolving the mismatch.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T18:54:27.643254+00:00— report_created — created