Server and client
Anything interactive, when you need state, an event handler or a browser API inside a section.
A section is server-rendered: it produces markup and ships no JavaScript of its own.
Anything that needs a browser — state, an event handler, a piece of a third-party
client library — is not written inside the section at all. It is an island: an
ordinary React component in its own "use client" module, mounted from the section.
What it is
// sections/units/UnitFilter.tsx
"use client";
import { useState } from "react";
import type { IslandEditor } from "@homepages/concrete";
export const editor = { live: true } satisfies IslandEditor;
export default function UnitFilter({ labels }: { labels: string[] }) {
const [open, setOpen] = useState(false);
return (
<div>
<button type="button" onClick={() => setOpen(!open)}>
Filter
</button>
{open ? <ul>{labels.map((label) => <li key={label}>{label}</li>)}</ul> : null}
</div>
);
}The section imports it and renders it like any component. Two declarations belong to the module rather than to the section:
editor— required, one field.live: truehydrates the island in the editor canvas, where it runs exactly its published behaviour;live: falseleaves it as its static server-rendered content. There is no state in between, and there is no omitted form: a missing declaration and a deliberate opt-out would otherwise be indistinguishable (islands/editor-declaration).serverFrame— optional, and only interesting when it is false: an island with no server-rendered first frame, mounted fresh in the browser instead of hydrated. A frameless island that is also not live would be a permanent blank hole, so the type refuses that pair outright, andislands/server-framecatches the other half — a module that declares no frame and then renders one anyway, which the build would delete from every published page.
Why it works this way
The pipeline establishes that your code runs at exactly two moments: once when a deliverable is published, and repeatedly behind the editor while a user edits. Neither of those is in a browser — the editor injects server-produced HTML into a frame rather than loading a bundle of your section. Three consequences follow, in order:
- A published page is rendered once and served as static files. A section that reached for a clock, a random number or a browser global could not be rendered at publish time at all: there is no browser present to answer it, and no request in flight to answer it differently next time.
- The editor re-renders your section repeatedly, against content that keeps changing under it. A section with side effects misbehaves every time that happens, not once — the same problem as the first, on a shorter clock.
- An island's props are embedded in the HTML the server produced and read back out
of that markup in the browser. They cross the boundary as data, not as live
references, which is why they must be JSON-serializable
(
islands/serializable-props).
How it works
The boundary is a file, and you draw it
"use client" is per module, not per component tree. Everything in a module without
it runs only where the page is built. Everything in a module with it also runs in the
browser, hydrated in place once the markup carrying it has loaded. Splitting a
section along that boundary is what lets the section stay a pure function of its
bindings: state, effects and event handlers all move to the island side and never
appear on the other.
server/no-client-runtime enforces it directly —
no browser-only hook or global, and no event-handler prop, in a module on the section
side of the line.
What an island may ask the platform for
Three hooks, all imported from the framework, all safe to call on a published page:
useEditorreturns whether this island is live in an editor canvas and what is selected inside its own section instance. On a published page it answers{ inCanvas: false, selection: null }, so it is hydration-safe by construction.useCaptureReadyholds the capture shutter for an island that keeps painting after mount — a map loading tiles, an async decode. Where nothing captures, the hold is never read and the hook costs nothing.useIslandIdgives an id stable across the server render and the browser's. Compose your own ids from it rather than from React's own id hook, whose counter starts from a different root on each side (islands/island-ids).
An island that has to reach the platform's own endpoints imports
@homepages/concrete/browser: submitLead for a lead form, and readSiteConfig
plus signedIngestHeaders underneath it for an endpoint submitLead does not cover.
Off a published page there is no site config, so nothing is sent and the call reports
that it was simulated — which is what makes a lead form safe to exercise in the
editor canvas and in local preview.
The editor's posture toward a live island
What the editor asks of a live island adds behaviour on top of the published
behaviour; it never replaces it. There are no editor modes, no half-hydrated state
and no framework-supplied fork. Where a genuinely published-only interaction
survives that test, the fork is an ordinary boolean conditional on what useEditor
returned — and it carries an editor-reason: comment saying why, which
islands/editor-reason requires of every one.
What it is not
Not React Server Components as a Next.js reader knows them. There is no per-request rendering — a deliverable renders once, at publish, not on each visitor's request — and no data fetching inside a section. Content arrives already decided, on the bindings.
Not a restriction on what a section may do. Interactivity is relocated, not banned. A filter, a slider, a lightbox are all ordinary things to build, in their own module, on the other side of the line.
Not a second React on the page. The server's markup and the island's hydration
target are the same markup, not two trees reconciled against each other. A workspace
that resolves two copies of React is a check error
(dependencies/single-react).
Where next
- The marker contract — how the editor finds its way from rendered markup back to the slot that produced it.
- The pipeline — the two moments that make all of this follow.
- Add an interactive island — the boundary drawn once, end to end.
- Add a lead form and
Gate content behind the lead form
— the two recipes over
submitLead. - Islands — the island contract, the three hooks and the
@homepages/concrete/browsersubpath, member by member.
