renderToReadableStream
renderToReadableStream renders a React tree to a Readable Web Stream.
const stream = await renderToReadableStream(reactNode, options?)- Reference
- Usage
- Rendering a React tree as HTML to a Readable Web Stream
- Streaming more content as it loads
- Specifying what goes into the shell
- Logging crashes on the server
- Recovering from errors inside the shell
- Recovering from errors outside the shell
- Setting the status code
- Handling different errors in different ways
- Waiting for all content to load for crawlers and static generation
- Aborting server rendering
Reference
renderToReadableStream(reactNode, options?)
Call renderToReadableStream to render your React tree as HTML into a Node.js Stream.
import { renderToReadableStream } from 'react-dom/server';
async function handler(request) {
const stream = await renderToReadableStream(<App />, {
bootstrapScripts: ['/main.js']
});
return new Response(stream, {
headers: { 'content-type'