0
0
NextJSframework~10 mins

How Next.js renders (server-first model) - Visual Walkthrough

Choose your learning style9 modes available
Concept Flow - How Next.js renders (server-first model)
User requests page URL
Next.js Server receives request
Server renders React components to HTML
Server sends HTML + minimal JS to browser
Browser displays HTML immediately
Browser runs React JS to hydrate page
Page becomes interactive
User interacts with page -> React handles events
This flow shows how Next.js first renders pages on the server, sends HTML to the browser, then hydrates React for interactivity.
Execution Sample
NextJS
export default function Page() {
  return <h1>Hello from Next.js!</h1>;
}
A simple Next.js page component that renders a heading on the server and sends HTML to the browser.
Execution Table
StepActionServer StateBrowser StateOutput/Effect
1User requests /pageWaiting for requestIdleRequest sent to server
2Server receives requestRequest receivedWaitingStart rendering React component
3Server renders <h1>Hello from Next.js!</h1>HTML generatedWaitingHTML ready to send
4Server sends HTML + JS to browserIdleReceiving HTML + JSBrowser starts parsing
5Browser displays HTMLIdleHTML renderedUser sees heading immediately
6Browser runs React JS to hydrateIdleReact hydrates DOMPage becomes interactive
7User clicks button (if any)IdleReact handles eventPage responds to user
8EndIdleInteractive pageRendering complete
💡 Rendering ends after hydration and page becomes interactive in the browser.
Variable Tracker
VariableStartAfter Step 3After Step 5After Step 6Final
Server HTMLNone<h1>Hello from Next.js!</h1><h1>Hello from Next.js!</h1><h1>Hello from Next.js!</h1><h1>Hello from Next.js!</h1>
Browser DOMEmptyEmpty<h1>Hello from Next.js!</h1><h1>Hello from Next.js!</h1> (hydrated)<h1>Hello from Next.js!</h1> (interactive)
React StateNoneNoneNoneInitializedActive
Key Moments - 3 Insights
Why does the user see content immediately before React runs in the browser?
Because Next.js sends fully rendered HTML from the server first (see Step 5 in execution_table), so the browser can display content right away.
What does hydration mean in Next.js rendering?
Hydration is when React runs in the browser to attach event handlers and make the static HTML interactive (see Step 6 in execution_table).
Does the server keep running React after sending HTML?
No, after sending the HTML and JS bundle, the server waits for new requests. The browser handles interactivity (see Steps 4 and 7).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step does the browser first display the page content?
AStep 5
BStep 3
CStep 6
DStep 2
💡 Hint
Check the 'Browser State' and 'Output/Effect' columns for when HTML is rendered.
According to the variable tracker, what is the state of React after Step 5?
AInitialized
BNone
CActive
DHydrated
💡 Hint
Look at the 'React State' row and the column for 'After Step 5'.
If the server did not send HTML first, how would the browser state change at Step 5?
ABrowser DOM would show the heading
BReact State would be active
CBrowser DOM would be empty
DServer HTML would be None
💡 Hint
Refer to the 'Browser DOM' variable in variable_tracker at 'After Step 5'.
Concept Snapshot
Next.js renders pages on the server first.
Server sends fully rendered HTML plus JS to browser.
Browser shows HTML immediately for fast display.
Then React hydrates HTML to add interactivity.
This server-first model improves speed and SEO.
Full Transcript
When a user requests a page, Next.js server receives the request and renders React components into HTML. This HTML is sent to the browser along with minimal JavaScript. The browser displays the HTML immediately, so the user sees content fast. Then React runs in the browser to hydrate the page, attaching event handlers and making it interactive. After hydration, the page responds to user actions using React. The server waits for new requests and does not keep running React for interactivity. This server-first rendering model helps pages load quickly and improves search engine optimization.