Skip to the page

Production incidents · Scenario

Next.js: hydration errors flood the logs

The interviewer asks

Since we moved the product page to server rendering, our logs show thousands of hydration errors a day. The page mostly looks fine. Should we care, and how do you fix it?

Then

Follow-ups the interviewer asks next

  1. What do you look at first in the error?
  2. Is anything broken for users right now, and how do you check?
  3. What are the usual causes, and how do you tell which one you have?
  4. The errors come mostly from users in India and from some browsers. What does that suggest?
  5. You can't change how the API sends dates this sprint. What do you do?
  6. What is the proper fix for each cause?
  7. How do you keep new mismatches out?
  8. Who do you tell?
  9. Have you fixed a hydration error? What caused it?

The answer

What a strong answer covers

  • Why care: on a mismatch 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 vs client values. Reads the diff and the component stack.
  • Causes: time and locale (new Date() and toLocaleString use the server's 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.
  • Twist: a split by country and browser points to time zone and locale, plus page translation in some browsers.
  • Fixes: formats dates with a fixed time zone and locale taken from the request, or formats on the client after mount. Uses useId for ids, client-only parts after mount or behind a client boundary, and fixed nesting. Uses suppressHydrationWarning only on one known text node, like a timestamp.
  • Knows React 19 skips unexpected tags that extensions insert in <head> and <body>, so the remaining errors are mostly in your own code.
  • Prevents it: reports hydration errors with their diff (onRecoverableError), runs e2e tests in another time zone and locale (Playwright timezoneId and locale), and lints HTML nesting.

The red pen

Common traps

Avoid:adding suppressHydrationWarning everywhere; "it's only a warning"; turning off server rendering for the whole page.

Practise this out loud

Say your answer out loud to an AI interviewer that follows up, and get a score for it.

Practise by voice

Practise questions like this out loud

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

Start your free interview