Dev.Lib
arrow_backBack to Blogs
LEVEL_077.3June 27, 20261 min read

Streaming SSR

Web Platform APIs

Send HTML shell early, stream completed segments as async data resolves — improves TTFB vs buffer-all SSR.

Summary

Send HTML shell early, stream completed segments as async data resolves — improves TTFB vs buffer-all SSR. Suspense boundaries map to stream chunks. Reverse proxies must not buffer entire response. Error mid-stream needs fallback HTML and status handling.

Code example

import { renderToReadableStream } from 'react-dom/server';

const stream = await renderToReadableStream(<App />, {
  bootstrapScripts: ['/client.js'],
});

return new Response(stream, {
  headers: { 'Content-Type': 'text/html' },
});

Key points

  • Send HTML shell early, stream completed segments as async data resolves — improves TTFB vs buffer-all SSR.
  • Suspense boundaries map to stream chunks.
  • Reverse proxies must not buffer entire response.
  • Error mid-stream needs fallback HTML and status handling.

Further reading

Related concepts