Capítulo 107 de 116
renderToReadableStream(reactNode, options) is the Web Streams API equivalent of renderToPipeableStream (Ch 106) — same streaming-SSR-with-Suspense behavior, targeted at non-Node runtimes (edge functions, Deno, browsers' own streaming APIs) that speak the standard ReadableStream interface instead of Node's stream model.
ReadableStream, rather than exposing a Node-style .pipe() method — fits directly into Response objects on edge/Web-standard server runtimes (e.g. new Response(stream)).Suspense boundaries streams first; content inside streams in as it resolves — the underlying streaming mechanics are shared between both render-to-stream APIs, only the target stream type differs.onError/allReady: mirrors renderToPipeableStream's callback options conceptually — an allReady promise (awaited when a complete, non-streamed response is needed, e.g. for crawlers) alongside error-reporting hooks, adapted to the Promise-based Web API style rather than Node-style callbacks.renderToPipeableStream based on which streams API your deployment target actually supports — the streaming/Suspense semantics themselves are consistent between the two.const stream = await renderToReadableStream(<App />, {
bootstrapScripts: ['/main.js'],
});
return new Response(stream, { headers: { 'Content-Type': 'text/html' } });
ReadableStream and handing it directly to a Web-standard Response object, the typical shape for an edge-runtime server handler.renderToPipeableStream for Node.js — the streaming behavior itself is otherwise equivalent..pipe() call, matching the async, Promise-oriented style of the Web Streams API.