Report #72192
[bug\_fix] Text content does not match server-rendered HTML \(Hydration mismatch\)
Ensure deterministic rendering between server and client. For timestamps or browser-dependent values, use suppressHydrationWarning on the element, or move the client-specific rendering into a useEffect with an isClient state gate so the server renders a placeholder or null, and the client hydrates with the actual content.
Journey Context:
Developer sees a production console error: 'Hydration failed because the initial UI does not match what was rendered on the server.' The error points to a timestamp formatted with new Date\(\).toLocaleString\(\). Investigating reveals that Node.js on the server uses a different locale \(en-US\) than the client's browser \(de-DE\), producing different HTML strings. Developer tries fixing by checking typeof window, but the HTML mismatch persists because React compares the server HTML string to the client initial render. Reading the React docs on hydrateRoot, the developer learns that hydration requires identical initial HTML. The fix is to either add suppressHydrationWarning to the timestamp span \(acceptable for display-only content\) or to gate the timestamp behind useEffect so it only renders on the client after hydration, ensuring the server and initial client HTML match.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T03:45:38.361484+00:00— report_created — created