Rendering & SSR

renderToStream

Streams an HTML response, flushing the synchronous shell first and then progressively emitting async-resolved fragments as their <Loading> boundaries settle. Good for time-to-first-byte sensitive pages.

Returns an object with pipe/pipeTo for piping to a Node Writable or a Web WritableStream, plus a then for awaiting full completion.


Import

import { renderToStream } from "@solidjs/web";

Type signature

function renderToStream<T>(
fn: () => T,
options?: {
nonce?: string;
renderId?: string;
noScripts?: boolean;
plugins?: any[];
manifest?: Record<
string,
{
file: string;
css?: string[];
isEntry?: boolean;
isDynamicEntry?: boolean;
imports?: string[];
}
>;
onCompleteShell?: (info: { write: (v: string) => void }) => void;
onCompleteAll?: (info: { write: (v: string) => void }) => void;
onError?: (err: any) => void;
}
): {
then: (fn: (html: string) => void) => void;
pipe: (writable: { write: (v: string) => void; end: () => void }) => void;
pipeTo: (writable: WritableStream) => Promise<void>;
};

Examples

import { renderToStream } from "@solidjs/web";
// Node:
renderToStream(() => <App />).pipe(res);
// Web (Workers / Deno):
await renderToStream(() => <App />).pipeTo(stream.writable);
Last updated: 7/4/26, 6:21 PMEdit this pageReport an issue with this page