Loading...
const html = renderToString(<App />);
await writeFile('dist/index.html', html);const { prelude } = await prerender(<App />, {
bootstrapScripts: ['/main.js'],
});
const html = await new Response(prelude).text();
await writeFile('dist/index.html', html);prerender waits for all <Suspense> data to load, so the static file contains real content instead of fallbacks.
renderToString for static pages and getting Suspense fallbacks instead of data.prerender is imported from 'react-dom/static' and used for static generation, not per-request streaming.prelude stream is what gets written to the HTML file or response.AbortSignal with a timeout is passed so slow data cannot hang the build.renderToReadableStream streams while data loads, for live requests. prerender waits for all data and returns finished HTML for static files.
Use prerenderToNodeStream from 'react-dom/static', which works the same way but returns a Node stream.