Next.js — 'Hydration failed' due to differences in date and time zone
Hydration failed in Next.js often means that the HTML generated on the server side (SSR) differs from the one React tries to initiate in the browser. One of the common but subtle reasons is different representations of the date or time zone: the server can render Date/Intl in the UTC zone or based on the server environment, and the client can render Date/Intl in the user zone. When components in SSR render contain textual date values (e.g. toLocaleString(), toISOString(), format from Intl.DateTimeFormat) the resulting HTML may contain a different string than the client side, leading to an error hydratation. The problem increases with dynamic, time-dependent elements:
How to Recognize Cause
Check that the component renders Date/Intl directly during SSR. If you use new Date() or Date.now() in the component body, the value may vary between building (SSG) and demand or customer.
Compare text output: Return HTML from the server (View Source) and compare with DOM after loading. The difference in time recording (e.g. '2026-11-07T10:00:00Z' vs '2026-11-07 11:00:00') indicates a zone problem.
Check using Intl.DateTimeFormat or toLocaleString without open locale and options. The server (Node.js) and the browsers can use different locale or timeZone by default, causing different renderings.
Step by step solution
1. Locate date rendering components: Search the code for toLocaleString, toISOString, Intl.DateTimeFormat, new Date() in page files and SSR/SSG components.
2 . Replace direct date formatting with conditional declaration: render neutral placeholder during SSR and format the date on the client side in useEfect or after hydrating.
3 . If you need a permanent format, use the open format: new Intl.DateTimeFormat('en-US',{ timeZone: 'UTC', hour12: false }) or formatting on the backend to make both environments use the same timeZone and locale.
4 . For SSG/SSR consider serialization of values as a number (timestamp) instead of a string; the client can read timestamp and format locally without differences in the DOM structure.
5 . If you use next/image or meta tags containing dates, generate them to be deterministic — e.g. canonicalDate = new Date(date).toISOString() — and avoid itLocaleString in HTML generado on the server.
6 . Run build locally in production mode (next build && next start) with the same environmental variables as production to repeat server conditions and see if an error occurs outside the developmental HMR.
How to see if the problem is gone
Test A: Open the page in the browser, save 'View Source' (HTML from the server) and compare with innerText doc.body after full loading; no discrepancy in the date places means correct hydration.
Test B: Change the timeZone in the formatter to another (e.g. 'UTC' vs 'Europe/Warsaw') and check if the hydratation is crashing again — if so, the cause was in a secret zone.
Test C: Enter the SSR placeholder (e.g. '—') and after hydrating in useEffect overwrite the formatted value; if the error disappears, the problem was in the SSR vs client rendering differences.
What to do
Do not use thisLocaleString() without open locale/timeZone in the SSR renderer — the effect depends on the environment and can cause hydration.
Avoid date formatting directly in JSX at SSR; instead, use serialization (timestamp) or clientocentric formatting after hydration.