Back to Blog
Bug Fixes•1 min read

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

Scaleup Infotech Team
Scaleup Infotech Team

Custom Software & Business Automation

Next.jsReactHydrationi18n

In this guide

A simple guide to this issue: 'Text content does not match server-rendered HTML' Warning. Learn why it happens, what to check first, and how to fix it.

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.

Relevant Scaleup Infotech Services

Share this article:

Keep Reading

Ready to implement these ideas?

Discuss Your Project