Skip to content
FrontDepth, Home

Back to the topic

Practice: Server rendering and hydration

Answer first, then compare. Rate yourself honestly — it drives your weak-areas list.

3 predict-output · 4 open

Questions up to level

Shows questions up to the selected level.

No practice questions for this level yet.

  1. Predict the outputMiddle

    The server formats an order in UTC with its default locale; the browser of a user in Baku uses its own. What does this code log?

    JavaScript
    const placedAt = Date.UTC(2026, 10, 16, 22, 30);
    const total = 1234.5;
    
    function renderOrder(locale, timeZone) {
      const date = new Date(placedAt).toLocaleDateString(locale, { timeZone });
      return date + " | " + total.toLocaleString(locale);
    }
    
    const server = renderOrder("en-US", "UTC");
    const client = renderOrder("az-AZ", "Asia/Baku");
    
    console.log(server);
    console.log(client);
    console.log(server === client);
    
    const fromCookie = { locale: "az-AZ", timeZone: "Asia/Baku" };
    console.log(renderOrder(fromCookie.locale, fromCookie.timeZone) === client);
  2. Predict the outputMiddle

    A form field gets its id from a module-level counter. The server process has already handled two requests; the browser loads the module fresh. What does this code log?

    JavaScript
    let nextId = 0;
    
    function renderEmailField() {
      nextId += 1;
      const id = "field-" + nextId;
      return '<label for="' + id + '">Email</label><input id="' + id + '">';
    }
    
    const idOf = (html) => html.match(/id="([^"]+)"/)[1];
    
    renderEmailField();
    renderEmailField();
    const serverHtml = renderEmailField();
    
    nextId = 0;
    const clientHtml = renderEmailField();
    
    console.log(idOf(serverHtml));
    console.log(idOf(clientHtml));
    console.log(serverHtml === clientHtml);
  3. Open questionMiddle

    What is hydration, and why must the first client render match the server HTML?

    Think it through first

    Answer out loud or in your head as if you were in an interview, then reveal.

  4. Open questionMiddle

    Compare CSR, SSR, static rendering and streaming SSR. How do you choose between them?

    Think it through first

    Answer out loud or in your head as if you were in an interview, then reveal.

  5. Predict the outputSenior

    This model reproduces what React 19 does with a mismatched text node (checked in Chromium): the server rendered Celsius, the user saved Fahrenheit. What does it log?

    JavaScript
    const saved = "F";
    
    function temperatureText(unit) {
      return unit === "C" ? "21 °C" : "70 °F";
    }
    
    function hydrateText(serverText, clientText, suppressWarning) {
      if (serverText === clientText) return serverText + " (kept)";
      if (suppressWarning) return serverText + " (kept, warning silenced)";
      return clientText + " (regenerated)";
    }
    
    const serverText = temperatureText("C");
    
    console.log(hydrateText(serverText, temperatureText(saved), false));
    console.log(hydrateText(serverText, temperatureText(saved), true));
    
    let unit = "C";
    console.log(hydrateText(serverText, temperatureText(unit), false));
    unit = saved;
    console.log(temperatureText(unit));
  6. Open questionSenior

    After a release, your error tracker shows Minified React error #418 on a server-rendered page. How do you investigate and fix it?

    Think it through first

    Answer out loud or in your head as if you were in an interview, then reveal.

  7. Open questionSenior

    How do streaming SSR and selective hydration work, and what problems do they solve?

    Think it through first

    Answer out loud or in your head as if you were in an interview, then reveal.