Scaleup Infotech
Scaleup Infotech.
Back to Blog
Bug Fixes6 min read

Fix 'Text content does not match server-rendered HTML' Warning

Scaleup Infotech

Scaleup Infotech

Software & Marketing Agency

Mar 29, 2026
Fix 'Text content does not match server-rendered HTML' Warning
Next.jsReactHydrationi18n

This is the gentler sibling of the full hydration crash: a single text node rendered differently on the server and client. It almost always comes down to formatting that depends on time or locale.

The Warning

Warning: Text content did not match. Server: "6/20/2026" Client: "20/06/2026"

Cause: Locale or Time-Dependent Formatting

The server formats a date using its locale/timezone; the browser uses the visitor's. toLocaleDateString() with no arguments is the usual offender because it silently picks up the environment locale.

Fix 1: Pin the Locale and Timezone

ts
new Intl.DateTimeFormat("en-GB", {
  dateStyle: "medium",
  timeZone: "UTC",
}).format(new Date(order.createdAt));

Fix 2: Format After Hydration

If the value must reflect the visitor's locale, render a neutral placeholder on the server and localize in useEffect:

tsx
const [label, setLabel] = useState(iso); // stable on server
useEffect(() => {
  setLabel(new Date(iso).toLocaleDateString());
}, [iso]);

Numbers Too

Number.toLocaleString() and currency formatting have the same problem. Pin the locale, or format on the client only.

Share this article:

Keep Reading

Ready to implement these ideas?

Work With Scaleup Infotech