The Web FrontendDeeper

Kayavak / The Web Frontend / FE·24 Full-stack Frameworks / Deeper

Deeper · The Web Frontend

Full-stack Frameworks

The questions the chapter doesn't stop for: why this exists, the model to keep in your head, what changes when an assumption does, how sure we are of each claim, and what's still open. Read it after the chapter; back to the chapter.

Why does this exist?

The web started with server rendering: CGI scripts, then PHP (1995), Rails (2004) and others produced finished HTML on every request. Single-page apps (2010s) moved rendering into the browser for richer interaction, and paid for it: blank pages until JavaScript loaded, poor results in search engines, slow phones doing all the work. Frameworks then tried to get both. Next.js (2016) made server rendering of React apps routine; static generation and incremental regeneration served pre-built pages from CDNs.

The cost that remained was hydration: the browser re-running every component's JavaScript just to attach event handlers to HTML it already had. The 2020s produced several answers: islands (named by Katie Sylor-Miller in 2019 and popularised by Jason Miller and Astro), where only interactive parts ship JavaScript; resumability (Qwik), which serialises enough state to skip re-running; and React Server Components (announced December 2020), which run only on the server and send no code to the browser.

The mental model

Try it yourself first: write your own model in the Mental Model Explorer, then compare.

Every page is built somewhere and at some time: on a build server, on a request server, at the edge, or in the browser. Choosing a rendering strategy is choosing where and when, per route, against freshness, speed and cost.

Question Answer
What is it? Frameworks that render pages on the server and the client, with routing, data loading and deployment conventions
Problem it solves Fast first loads and search visibility without giving up rich interactivity
Parts Rendering modes (CSR, SSR, SSG, ISR, streaming, islands, Server Components), data fetching, caching, hydration
How it works HTML is produced ahead of time or per request; the browser shows it at once and hydrates what's interactive
Assumptions Server and client render the same output for the same data
When they change Hydration mismatches (dates, randomness, browser-only APIs) force client re-rendering and errors
Where it fails Complexity: caching layers and server/client boundaries make bugs harder to locate
Related ideas Caching (ch19); performance metrics (ch27); deployment targets (ch31)

What if?

What if you hydrated nothing?

Reason it through, then open

The page would load fast and look complete, and no button would work: the HTML is there, the event handlers aren't. That's the honest baseline: decide which parts must be interactive and hydrate only those. Islands architecture makes that the default; Server Components do it at component granularity inside React.

What if every page were statically generated at build time?

Reason it through, then open

Pages would be as fast and cheap as possible to serve, and stale until the next build. Sites with thousands of pages would take long to build, and anything personal (a cart, a dashboard) couldn't be pre-rendered at all. Incremental regeneration rebuilds pages after a time or on demand, trading a little staleness for scale.

Where the boundary is

Aspect Server-side rendering (SSR) Static generation (SSG)
HTML built On every request Once, at build time
Fresh data Always Only after a rebuild or revalidation
Server cost Per request Almost none (CDN files)
Personalised pages Yes No, except through client-side fetching

How sure are we?

Claim How it's known Where from
Hydration re-runs component code in the browser Convention How React, Vue and others implement it
Server Components send no JavaScript for server-only components Convention React's design; client components still ship
SSR improves Largest Contentful Paint Measured, conditionally Usually, if the server is fast and close; a slow server can make it worse
"Islands" named in 2019, popularised from 2020 Historical Sylor-Miller's talk; Jason Miller's 2020 article

Still open

Frameworks are still converging and diverging: React Server Components' complexity is debated, edge rendering's benefits depend on where the data lives, and simpler hypermedia approaches have a revival. No strategy fits every route.

What would change your mind? If client-side rendering on typical phones matched server rendering's first-load times, the whole server-side movement would lose its main reason. Measurements on median devices still say otherwise.

Recall

What does hydration cost?

Downloading and re-running the JavaScript of every hydrated component to attach behaviour to existing HTML.

What's an island?

An interactive component that ships JavaScript inside an otherwise static page.

When is static generation the wrong choice?

For personalised or constantly changing pages, or very large sites where builds take too long.

What causes a hydration mismatch?

Server and client rendering different output, e.g. from dates, randomness or browser-only APIs.

Reflect

Be honest with yourself; this stays in your browser. Anything you can't tick yet is what to revisit.