Report #14572
[bug\_fix] Hydration failed because the initial UI does not match what was rendered on the server. Text content does not match: Server: "2024-01-15" Client: "2024-01-16"
Move any time-sensitive or browser-only data \(like \`new Date\(\)\`, \`Math.random\(\)\`, \`window\` access\) 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., timestamps\).
Journey Context:
Developer builds a dashboard with Next.js App Router that displays 'Last updated: \{new Date\(\).toLocaleDateString\(\)\}'. In development \(\`next dev\`\), it works perfectly, but production builds \(\`next build && next start\`\) crash on load with a hydration mismatch error showing different dates for Server vs Client. They first suspect timezone misconfiguration \(server UTC vs client PST\), then try to format the date identically on both sides using \`toISOString\(\)\`, but fail because the server renders at build time with one timestamp while the client hydrates seconds later. After inspecting the React error stack, they realize the HTML string literal differs between server and client. They move the date generation into \`useEffect\(\(\) => setDate\(new Date\(\)\), \[\]\)\`, rendering a placeholder initially. This resolves the error because the server and client HTML now match during hydration; the actual date only injects after the component mounts client-side.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T21:51:44.164214+00:00— report_created — created