Production incidents · Scenario
Next.js: hydration errors flood the logs
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voiceThe 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
- What do you look at first in the error?
- Is anything broken for users right now, and how do you check?
- What are the usual causes, and how do you tell which one you have?
- The errors come mostly from users in India and from some browsers. What does that suggest?
- You can't change how the API sends dates this sprint. What do you do?
- What is the proper fix for each cause?
- How do you keep new mismatches out?
- Who do you tell?
- 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()andtoLocaleStringuse the server's time zone and locale),Math.randomor generated ids,typeof windowbranches, readinglocalStorageduring 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
useIdfor ids, client-only parts after mount or behind a client boundary, and fixed nesting. UsessuppressHydrationWarningonly 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 (PlaywrighttimezoneIdandlocale), 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 voicePractise 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.