Rendering tiers

Rendering tiers

Every component is given one of three tiers when you build. The tier decides what the browser receives for it — and only one of the three sends the component's own JavaScript. You do not annotate anything: the compiler reads the code.

The three tiers

TierThe componentThe browser receives
Aholds no stateHTML, rendered once at build time. No JavaScript
Bholds state the server owns — shared, stored, or per requestHTML, rendered by the server. No component JavaScript; changes arrive over the page's one live connection
Cholds state only this browser tab cares aboutHTML, plus a small compiled island for that component alone

The question behind the letters is who owns the state.

A guestbook's rows belong to the server: every visitor has to see the same list, so the rows can never live in one browser. Its changes are sent from the server as instructions over a connection the page already has, and no component code is shipped. That is Tier B — neither static nor shipped, and the tier most frameworks do not have.

A counter's number belongs to one tab. Nobody else will see it, so routing each click through the server would buy a round trip and nothing else. It gets an island. That is Tier C, and it is the right answer, not a failure.

A heading with no state at all is Tier A.

Reading the decision

albedo build prints every component with its tier and the reason:

A Hero        no hooks, no async, no IO, no side effects - static markup
B Guestbook   state escapes this client - server-owned, no component JS
B SignIn      reads `user` - rendered per request, no component JS
C Counter     hooks + a client-satisfiable handler - ships a client island

Trust that output over any description of it, including this one. It is the decision, not a summary.

What moves a component

The decision is made from the component's code. The first rule that matches decides:

  1. An effect on mount (useEffect, useLayoutEffect) — the effect has to run in the browser, so C.
  2. A network or file call in the component (fetch and the like) — made from the browser, so C. A call in a server action is not in the component and does not count.
  3. async — awaited on the server, so B. With a handler that can run entirely in the browser, C.
  4. Hooks whose state leaves the tab — a live collection read with useSharedSlot, a write to a collection, a server action — the server owns it, so B. Hooks with a handler that runs entirely in the browser — local state — C. Other hooks, B.
  5. No event handler, no user, no route params, no npm import — nothing left that needs a request or a browser, so A.
  6. Imports an npm package — rendered on the server through the embedded JavaScript engine, so B. No component JavaScript is sent for this.
  7. Reads user, or a [segment] route's params — the signed-in person and the visited URL are known only per request, so B.
  8. Anything else — a handler with no state behind it — B.

Adding useState to a Tier A component moves it at the next build; removing it moves it back.

What it costs

  • A costs its markup.
  • B costs its markup. Its live changes are applied by ALB'DO's shared client, which the page loads once.
  • C adds that component's compiled island, and only it: never the page around it.

Note

In 1.0 every page loads the shared client — about 8 KB compressed — even a page made only of Tier A components, such as this one. Leaving it off pages that have nothing for it to do is a known gap.

albedo budget checks each route against the ceilings in tier-budget.toml, and albedo build fails when one is exceeded.

Next: data.