liveBook · Manning

Server-side rendering

As explained in Build a Frontend Web Framework (From Scratch)

A rendering approach in which the server generates the HTML for an application before sending it to the browser.

Server-side rendering (SSR) generates an application's HTML on the server before sending it to the browser. A backend handles requests, selects the components for the requested route, loads their data, and produces the initial markup. section 1.3.1 section 1.3.3

A typical SSR request follows these responsibilities:

  • Receive the browser's request for an application URL. section 1.3.3
  • Use the application router to determine which components match the requested route. section 1.3.3
  • Instantiate those components, load data from other servers or databases, and run their mounting code. section 1.3.3
  • Render the components as complete HTML and send the result to the browser. section 1.3.3

The returned page looks like static HTML, but the server creates it for each request. It initially lacks application event handlers, so hydration matches the HTML with virtual DOM nodes and attaches the handlers needed for interaction and dynamic updates. Navigating to another route requests a new HTML page from the server rather than updating the markup programmatically. section 1.3.3

Figure 1.15 The complete flow of an SSR application—rendered in the server and hydrated in the browser
figure

Use the complete-flow diagram to connect server rendering, browser hydration, and subsequent interaction. section 1.3.3

How Build a Frontend Web Framework (From Scratch) covers it

How deep it goes
Defines the request, component, rendering, and hydration pipeline but stops short of implementation details.
Examples
Uses URL requests, route-selected components, loaded database data, generated HTML, and hydration flow diagrams as examples.
What it assumes
Assumes familiarity with SPAs while introducing server-generated HTML and hydration as contrasting application behavior.
What you can do after
Understand how an SSR request becomes interactive browser markup through server rendering and hydration.
How it connects
Connects SSR with SPAs, application routers, components, virtual DOM nodes, hydration, and browser interactions.

Also explained in

Compare how 8 books explain server-side rendering →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Frontend Web Framework (From Scratch). The section links point to the parts of the book it draws on.