Skip to article content
LESSON 01 / 28

From request to interactive screen

Trace one catalogue request through HTTP, server rendering, browser rendering and hydration before learning individual framework APIs.

What you will be able to do

  • Separate a network request from a React render and a DOM commit.
  • Explain HTML, the RSC payload and client JavaScript in one page load.
  • Collect evidence about execution instead of guessing from a filename.

Start with the request contract

A URL identifies a resource; it does not identify the machine that must calculate every pixel. For our catalogue, the browser asks for a page, the application decides which data may be read, and the response carries information the browser can display. A response can be a document, JSON, a stream, a redirect or a failure. React is one part of producing and updating the interface. HTTP still determines methods, status codes, headers and how responses travel.

Before coding, write three observable requirements: a direct catalogue visit shows meaningful content, a cart button responds after its JavaScript becomes ready, and a private supplier token never appears in a browser response. These requirements force separate decisions about delivery, interactivity and security. A visually correct screenshot proves none of the latter two. This is why a good interview explanation connects a mechanism to a user-visible requirement and then describes how to verify it.

Understand the three delivered artifacts

On an initial App Router visit, HTML gives the browser visible markup. The React Server Component payload describes the server-rendered tree, references to client modules and data passed across the boundary. Client JavaScript provides interactive behavior. These artifacts cooperate, but they answer different questions: what can be painted, how React reconstructs the tree, and which event handlers can run. A small HTML response can still require an unnecessarily large JavaScript download.

Imagine a product description and an Add button. The description can be produced entirely on the server; the button needs browser interaction. Giving the button an event handler does not require moving the product database query into the browser. Conversely, rendering the button into HTML does not mean its handler is already attached. A useful diagnostic is to slow script downloads: content may be visible before the interface accepts interaction. Record that interval rather than describing the whole page as simply loaded.

PAUSE AND PREDICT

The catalogue title and price are visible, but a stateful button starts responding only when a delayed JavaScript request finishes. Which explanation best fits this trace?

Choose one answer, then check your reasoning.

This check does not mark the lesson as solved.

Compare first visits with later navigation

A hard navigation creates a document request. After the app is running, a Next Link can navigate by fetching route information and reconciling the existing tree. Shared layouts may remain mounted, so navigation is not equivalent to reloading every component. Prefetching can make a future navigation partly prepared before the click. Browser history and caches add more possibilities, which is why one click does not guarantee one newly executed server function.

For the interview, draw an execution trace with separate server, network and browser columns. Put each observation where it was measured: terminal output, Network panel or browser console. Do not infer that a client-module console message must appear only in the browser. Initial rendering can execute client component rendering on the server too. Also do not treat development logs as production evidence: development checks and refresh behavior can repeat work.

Turn the model into a debugging procedure

Open the real lab at /catalog in a fresh tab, inspect the document response, then follow a product link. Compare request types, transferred resources and which pieces of UI retain state. Add a temporary log to a server page and a separate log inside a browser event handler. The former describes rendering work; the latter proves an interaction actually occurred. Remove noisy logs after the observation and preserve the hypothesis in your notes.

When an interviewer says the page is slow, ask which stage is slow. Waiting for headers suggests a different investigation from downloading a large client bundle or blocking the main thread after a click. Start with evidence for the slow stage, isolate one dependency, change it, and measure again. The exercise below practices organizing an already observed trace. It deliberately does not pretend to implement the Next.js renderer or predict framework internals.

Client module

app/catalog/TraceButton.tsx
'use client';
import { useState } from 'react';
export default function TraceButton() {
  const [clicks, setClicks] = useState(0);
  return <button onClick={() => setClicks(value => value + 1)}>
    Confirm interaction: {clicks}
  </button>;
}

PAUSE AND PREDICT

A component starts with use client. A log in its render appears in the server terminal on a fresh visit. What is the strongest explanation?

Choose one answer, then check your reasoning.

This check does not mark the lesson as solved.

Misconceptions to replace

Compare the tempting shortcut with the model you can verify in code.

CLAIM TO CHALLENGEEvery React render creates a network request.
A more accurate model

A local state update can render entirely in the browser. Track rendering and fetching as separate events.

How to check it

R01 explains render snapshots; N04 and N06 distinguish navigation and rendering delivery.

CLAIM TO CHALLENGEHTML, the RSC payload and client JavaScript are interchangeable names for the same thing.
A more accurate model

They have different jobs: visible markup, server-tree representation and interactive client behavior. Their delivery can overlap.

How to check it

N06 describes the initial server and client rendering sequence; the request-to-screen lab observes their roles.

Mistakes to catch in your own code

  • A server-rendered screenshot does not prove that hydration succeeded.
  • A Client Component may participate in initial server rendering.
  • A missing console log can mean cached or prefetched work, not necessarily a broken route.

Write it by hand

JavaScript logic playground

Organize an observed execution trace

Implement solve(input). This sandbox runs the lesson's logic with FrontendX's isolated code runner. Next.js server behavior is verified in the project lab below.

  1. Implement solve({events}). Each event has a where value of server, network or browser and a label. Return the labels grouped by those locations in original order.
  2. Set interactive to true only when a browser event has label hydrated. Ignore events whose location is unknown. Do not mutate the input.
  3. This is a trace-analysis kernel. It does not execute React, hydration or the Next.js server.

Tab moves to the next control. Use spaces to indent and return your answer from solve. Console output is not retained.

Ready when you are. Try the exercise before opening the worked solution.
Inspect 4 test cases
  1. Visible before interactive

    Input

    {
      "events": [
        {
          "where": "server",
          "label": "render"
        },
        {
          "where": "network",
          "label": "html"
        },
        {
          "where": "browser",
          "label": "paint"
        }
      ]
    }

    Expected

    {
      "server": [
        "render"
      ],
      "network": [
        "html"
      ],
      "browser": [
        "paint"
      ],
      "interactive": false
    }
  2. Interleaved events preserve location order

    Input

    {
      "events": [
        {
          "where": "browser",
          "label": "paint"
        },
        {
          "where": "server",
          "label": "reviews"
        },
        {
          "where": "network",
          "label": "chunk"
        },
        {
          "where": "browser",
          "label": "hydrated"
        }
      ]
    }

    Expected

    {
      "server": [
        "reviews"
      ],
      "network": [
        "chunk"
      ],
      "browser": [
        "paint",
        "hydrated"
      ],
      "interactive": true
    }
  3. Only browser hydration counts

    Input

    {
      "events": [
        {
          "where": "server",
          "label": "hydrated"
        },
        {
          "where": "unknown",
          "label": "noise"
        }
      ]
    }

    Expected

    {
      "server": [
        "hydrated"
      ],
      "network": [],
      "browser": [],
      "interactive": false
    }
  4. Empty trace

    Input

    {
      "events": []
    }

    Expected

    {
      "server": [],
      "network": [],
      "browser": [],
      "interactive": false
    }
Reveal the worked solution and reasoning
solution.js
function solve(input) {
  const result = { server: [], network: [], browser: [], interactive: false };
  for (const event of input.events) {
    if (!['server', 'network', 'browser'].includes(event.where)) continue;
    result[event.where].push(event.label);
    if (event.where === 'browser' && event.label === 'hydrated') {
      result.interactive = true;
    }
  }
  return result;
}

Each observation has one location, so one pass preserves order without inferring hidden events.

The hydrated label is meaningful only when the observer is the browser. The real lab is where that assumption must be measured.

Verify it in a real Next.js application

Next.js application lab

Trace the actual catalogue lifecycle

Open the local application route /catalog after starting the workbench. Follow the experiment and collect the evidence described below.

Make the change

  1. Use Download project or Open in playground in the course lab panel. Follow the included README; for runtime observations, install locally, run the production build and start the server.
  2. Visit /catalog?q=keyboard directly with the Network panel open. Inspect the document response, then click Mechanical keyboard to open the shipped intercepted modal.
  3. Reload /catalog/keyboard and compare the standalone product page with the modal navigation. Add the product to the cart, visit /cart and use browser Back.
  4. Write an observation table for direct document loading, internal navigation, initial client rendering and a cart event. Record what you observed before JavaScript interaction became available.

Check the behavior

  • Catalogue content exists in a direct response, and a product URL works without a previous catalogue visit.
  • Soft product navigation and a hard reload produce the intended modal and standalone views.
  • The cart button changes browser state after hydration.
  • The trace identifies actual request types and observations without assuming an exact request count.
Review the application reasoning

Prefetch, caches and the production build can change when work happens. A network request is evidence to investigate, not proof that every component executed in the browser.

The pure exercise verifies trace processing only. These observations exercise actual Next.js rendering, routing and hydration.

Open the project files and run instructions

A complete App Router application with catalogue routing, cart state, a task dashboard, practice sessions, tenant checks, cached data, hydration repairs, and HTTP streaming. Next.js 16.4.6 and React 19.3.0 are pinned in the project.

The playground opens a new editable copy. A local Node.js 22.14+ installation also runs the project. Use the local production build when measuring caching, streaming, or deployment behavior.

Terminal
cd nextjs-interview-lab
npm ci
npm run dev

# In a second terminal
npm test

# Stop dev, then verify the production application
npm run build
npm start

# In a second terminal, install the test browser once
npx playwright install chromium
npm run test:e2e

Open http://localhost:3003. The project includes a credential-free practice account selector and a single-process file store. Those choices make experiments reproducible; the security and deployment lessons show what a production system needs.

Explain it in an interview

Give your answer aloud before opening the explanation. Then answer the follow-ups using your implementation as evidence.

  1. 01What does Next.js send on the initial visit?

    Explain the roles separately: HTML supplies visible markup, the RSC payload represents the server tree and its client references, and JavaScript enables the client interactions. Their timing and delivery can overlap. I would inspect the actual response and browser requests instead of claiming they always arrive as three separate files.

    Follow-up questions

    • What still works if JavaScript is delayed?
    • How does a subsequent Link navigation differ?
  2. 02Does use client mean the component runs only in the browser?

    No. It establishes a client module boundary. A Client Component can be rendered on the server for an initial visit and then hydrated in the browser. Its render must therefore avoid assuming browser-only globals are available, while browser event handlers and Effects have a different lifecycle.

    Follow-up questions

    • Where would window access belong?
    • Why can a client component cause a hydration error?
  3. 03How would you investigate a slow catalogue page?

    I would first identify whether the delay is response latency, resource transfer, rendering or interaction. Then I would inspect the critical dependency for that stage: a server data waterfall, excessive client code or expensive browser work. I would repeat the same production-mode scenario after a targeted change and compare measurements.

    Follow-up questions

    • Why can next dev mislead you?
    • What evidence would distinguish network time from CPU time?
  4. 04Is every React render a network request?

    No. Local state can cause a browser render without contacting the server. A network response can also arrive without a useful UI update if it is stale or ignored. Rendering, fetching and committing DOM changes are different events, so I trace them independently when investigating repeated requests or unexpected UI.

    Follow-up questions

    • What causes a state update after a response?
    • Can prefetch happen without a click?

Check your understanding

Answer these without reopening the worked examples. The feedback explains the reasoning and the misconception behind each choice.

FINAL KNOWLEDGE CHECK

You must verify that a catalogue route works for a first-time visitor and during later navigation. Which evidence is strongest?

Choose one answer, then check your reasoning.

This check does not mark the lesson as solved.

Your checkpoint

Mark what you can do independently

Loading your local progress.

Sources and further reading

© 2026 FrontendX. All rights reserved.