Report #102877
[bug\_fix] Hydration mismatch: 'Text content does not match server-rendered HTML.'
Use \`useEffect\` to set any client-only data after mount, or wrap client-only content in a component that defers rendering until after hydration \(e.g., using a \`useState\` \+ \`useEffect\` pattern\). Alternatively, suppress the warning with \`suppressHydrationWarning\` on the element if the mismatch is intentional and harmless.
Journey Context:
I was building a Next.js app with server-side rendering. The app displayed a timestamp in the header using \`new Date\(\).toLocaleString\(\)\`. On initial load, the server rendered time and the client time differed, causing React hydration to fail with the mismatch error. I attempted to use \`typeof window === 'undefined'\` to conditionally render on server, but that created a flicker. After reading the Next.js hydration docs, I understood that SSR produces static HTML and the client React re-hydrates that HTML; any difference between server and first client render triggers the error. The proper fix was to render a placeholder on the server \(e.g., an empty span\) and then populate the time with a \`useEffect\` after mount. I moved the dynamic content into a client component, used \`'use client'\`, and set state inside \`useEffect\` to ensure it only runs on the client after hydration. That eliminated the mismatch.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-09T15:49:13.213434+00:00— report_created — created