Skip to content
FrontDepth, Home

2020 – today

Server components and islands

The server sends the page as HTML, and only the interactive parts, the islands, get JavaScript and hydrate on their own.

MiddleSeniorRuns on: React 19.3.0, React DOM 19.3.0

The problem

Server rendering made the first paint fast, but hydration still downloaded and ran the code of every component on the page, including headings, articles and footers that never change, and the page did not respond until the whole tree had hydrated. Yet many pages are mostly static content with a few interactive widgets.

The idea

Islands (a name coined by Katie Sylor-Miller and described by Jason Miller in 2020): the server renders the whole page to HTML, and only the interactive regions hydrate, each on its own, as small self-contained widgets. Here Intro is rendered with renderToStaticMarkup(), which leaves no hydration markers and ships no code. TodoApp is rendered with renderToString(), its props go next to it as JSON, and client.jsx calls hydrateRoot() on the island's element only. Astro works this way: components are static HTML by default, and a client:* directive such as client:visible turns one into an island and decides when it loads.

React Server Components go further, and they are not shown here. A server component can read data directly and never reaches the bundle; "use client" marks where the interactive components start; the server sends a serialized tree, the RSC payload, which React uses to fit the server's output and the client components together. That needs a server runtime and a bundler that understands those boundaries, and this sandbox has neither.

What hurt next

Inside an island, and inside every client component, nothing changed: each state change runs the component again and React compares the new output with the old. Ticking one checkbox here re-renders the whole TodoApp and compares every item; keeping large islands fast takes memo, useMemo and useCallback. Signals and fine-grained reactivity track which piece of the DOM reads which value and update only that.

Next era: Signals and fine-grained reactivity

How close this is to the original

Runs React 19.3.0 with function components and hooks: renderToStaticMarkup for the static parts, renderToString and hydrateRoot for the island. The island wiring is written by hand here; Astro generates it and wraps each island in an <astro-island> element that carries the component's script URL and its serialized props. React Server Components do not run here: they need a server runtime and a bundler that understands "use client" and the RSC payload, as in the Next.js App Router (stable since Next.js 13.4). React 19 calls Server Components stable, but the APIs for building such a bundler or framework may still change between minor versions. Intro only plays the part of a server component: it becomes plain HTML, not an RSC payload.

The todo app in this era