Skip to the page

Concurrent React and Suspense · senior

Server rendering, streaming and hydration

Server rendering sends HTML so users see content early; hydration then runs the components again in the browser and attaches event handlers to that HTML, which only works if the client's first render produces exactly the same output as the server.

The notes

What you must know

  • APIs: renderToPipeableStream (Node) / renderToReadableStream (Web Streams) on the server; hydrateRoot(container, <App />) on the client. prerender/resume (React 19.2) power Partial Prerendering.
  • Streaming: with Suspense, React sends the shell first and streams each boundary's HTML later in the same response.
  • Selective hydration: boundaries hydrate independently, and React hydrates the part the user interacts with first.
  • Hydration mismatch causes: dates and time zones (server UTC vs browser IST), Math.random()/Date.now(), typeof window branches, localStorage-based UI, invalid HTML nesting (<div> inside <p>), browser extensions.
  • Fixes: deterministic output (explicit time zone and locale), stable ids with useId, client-only parts rendered after hydration, suppressHydrationWarning only for one intentional text difference (like a timestamp).
  • React 19.3 use(browser()) (from react-dom): suspends on the server so the fallback goes into the HTML, then renders on the client after hydration; it replaces mounted flags and typeof window checks.
  • React 19 shows one error with a diff for mismatches and skips unexpected tags injected into <head>/<body> by extensions.
  • Hydration costs JavaScript and CPU; Server Components reduce what must hydrate.

The red pen

Common traps: mistake → fix

  • Mistake: "SSR means no JavaScript on the client"

    Fix: the client still downloads JS and hydrates.

  • Mistake: "typeof window !== "undefined" in render is the fix for client-only code"

    Fix: it causes mismatches; render client-only parts after hydration or use browser().

  • Mistake: "suppressHydrationWarning everywhere"

    Fix: it hides real bugs and only works one level deep.

Easy to hard

Questions interviewers ask, easy to hard

  1. What is hydration and what does it cost?
  2. If HTML is rendered on the server, how does JavaScript work afterwards?
  3. We get a hydration mismatch on a component that formats dates. First hypothesis? Other causes?
  4. How do streaming and selective hydration work together?
  5. How do you render a component that reads localStorage without a mismatch in React 19.3?

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