AsterDocsv1.2.3

Docs / Architecture

Streaming and scoped context

A slow request presents two separate problems for a server-rendered view. The server must choose when to send HTML, and the browser must be able to attach handlers to the markup that arrives. A page serving several users at once also needs to keep each request's data inside its own render tree.

Find the right DOM range

The browser can merge adjacent text nodes while parsing HTML. In a revivable island, Aster emits comment markers around dynamic node slots so the client can find the corresponding range. Keep the markers when processing the HTML. During activation, compatible nodes can be reused. A mismatch can require a local remount. Inspect a server-rendered island.

Choose when to send the response

Use renderToStringAsync() when the caller needs one resolved HTML string. Use renderToStream() or streamResponse() when the response can send a shell and update individual regions as work completes. Yield a loading view before waiting for a slow request. Set a nonce on the document options when the site's content security policy requires one for the inline swap scripts. Network buffering and the generator's first yield both affect when readers see content. See the streaming response example.

Keep request data in the tree

Provide the current user's value at the root of that request and read it from descendants. A module-level mutable value is shared by requests that use the same module instance. On a runtime without asynchronous context storage, capture the context value before the first await. Pass ctx.signal to operations that support cancellation so they can settle when a component is replaced. Read about context and prop restarts and inspect the cancellation trace.

Summary of the architecture decision accepted on 2026-11-24.