docs(rfcs): propose a first navigation that does not wait for the renderer

Merged
KI
14d ago
+204-11

Problem

An islands first navigation waits for React DOM even when it never renders with it. The router chunk imports its shared bindings from the client entry, which imports react-dom/client. So a streamed (docs, blog) navigation can't start until the whole runtime has downloaded and evaluated.

  • At 150 ms latency and 1.6 Mbit/s (Lighthouse's mobile profile), a first tap was 434 to 570 ms slower than the rsc engine's on every section.
  • On an instant tap with bandwidth to spare, it was 33 to 81 ms slower.

Change

Adds RFC 0010 and lists it in rfcs/README.md. It decides on this approach:

  • In an islands web build with React and no client route slots, the generated entry imports react-dom/client and islx when it first renders or hydrates, not at the top. The router, which imports the entry, runs without them.
  • A navigation that streams its page swaps it in, then hydrates its islands once React DOM and islx arrive. Until then the entry holds a click on an unhydrated island.
  • A navigation into a layout's React root, a lazily loaded route component, and hydrate() wait for the renderer, as before.
  • The mobile client and apps with client route slots keep the static import.

The RFC records why the contract holds, what it costs, and the alternatives:

  • Splitting a renderer-free farm-client-core chunk, the first version of this RFC.
  • Idle preload of the runtime.
  • Document navigation for a held click.
  • Trimming the runtime.
  • V8 compile hints.

#3061 implements it.

Safety and compatibility

No code changes here. The RFC keeps RFC 0003's promise that a reader who never navigates or interacts loads no runtime, and it adds no config.

Verification

  • oxfmt --check on rfcs/README.md and rfcs/0010-renderer-free-first-navigation.md: clean.
  • The Problem figures come from benchmarks/server-components-payload: first-navigation.mjs from #3042, a source-mapped islands build, and Chrome traces.
  • The Results come from first-navigation.mjs run against #3061, interleaved with a build from before it.

Documentation and release

The RFC itself. No package or release changes.


Summary by cubic

Adds RFC 0010 (Draft), which proposes that a first islands navigation stops waiting for React DOM before swapping in a streamed page. Today the router imports the client entry, which imports react-dom/client, so a streamed navigation waits for the full runtime even though only hydration needs it; the RFC records that a first tap is 434–570 ms slower than the rsc engine's on a mobile profile. It also lists the RFC in rfcs/README.md.

The proposal

  • The islands entry loads React DOM and islx lazily on its first render or hydration, so a streamed navigation swaps the page before they arrive, then hydrates the new page's islands when the renderer gets there.
  • The boot preloads the renderer only when the start renders or hydrates at once; streaming links leave it out so the page request, entry, and router get bandwidth first.
  • Eligibility checks keep today's renderer-first order for tree payloads, React-owned roots, and apps with client route slots or plugins that import React DOM.
  • Documents measured results and the alternatives: a renderer-free core module (first draft), idle preload, document navigation, runtime trimming, and V8 compile hints.

Docs-only change: no code, keeps RFC 0003's no-runtime-for-readers promise, and adds no config.