Skip to the page

Errors and releases that break pages · mid

Hydration mismatches in server-rendered apps

A hydration mismatch means the server HTML and the first client render differ. React then renders that part again on the client, which costs speed and buries real errors in noise.

The notes

What you must know

  • Why care: React throws away the server HTML for that part and renders it again on the client. That means slower LCP and INP, flicker, wasted server work and real errors buried in noise.
  • React 19 logs one message with a diff of server and client values. Read the diff and the component stack.
  • Causes: time and locale (new Date() and toLocaleString use the server time zone and locale), Math.random or generated ids, typeof window branches, reading localStorage during render, invalid HTML nesting (div inside p), and extensions or translation tools changing the DOM.
  • A split by country and browser points to time zone and locale, and page translation in some browsers.
  • Fixes: format dates with a fixed time zone and locale taken from the request, or format on the client after mount. Use useId for ids, client-only parts after mount or behind a client boundary, and correct nesting.
  • Use suppressHydrationWarning only on one known text node, like a timestamp.
  • React 19 skips unexpected tags that extensions insert in head and body, so the remaining errors are mostly in your own code.
  • Prevent: report hydration errors with their diff (onRecoverableError) and run end-to-end tests in another time zone and locale (Playwright timezoneId and locale).

The red pen

Common traps: mistake → fix

  • Mistake: Hydration errors are only console noise

    Fix: they cost performance and hide real errors.

  • Mistake: suppressHydrationWarning fixes it everywhere

    Fix: use it only for one known text node.

  • Mistake: Server and client run in the same time zone

    Fix: they often do not.

Easy to hard

Questions interviewers ask, easy to hard

  1. Hydration errors flood our logs after a release. What do you do?
  2. What are the most common causes of a mismatch?
  3. Errors appear only for users in one country. Why?
  4. How do you prevent them in tests?

Practise

Practise with these questions

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview