Streaming SSR at the Edge: RSC and HTML Streaming
Buffered SSR makes users wait for the slowest query before they see anything. Streaming flips that: send the shell now, fill the gaps as data lands.
Key takeaways
- Streaming SSR sends the page shell immediately and fills Suspense boundaries as slow data resolves, so time to first byte depends on the shell, not the slowest query.
- React's renderToReadableStream does this on any Web Streams runtime.
- Status codes are locked once the shell flushes, and buffering proxies silently undo the benefit.
On this page
Streaming SSR sends the page shell as soon as it renders and fills each Suspense boundary as its data resolves, so time to first byte tracks the shell, not your slowest query. Use React's renderToReadableStream on Web Streams runtimes, wrap only the slow reads in Suspense, and do auth and redirects before the first flush.
Verified against
React 19.3 and Next.js 16.4, against the react.dev renderToReadableStream reference, the Next.js route segment config docs and the nginx ngx_http_proxy_module docs. Checked October 2026.
Buffered server rendering has one bad habit: it holds the whole response until every piece of data is ready. Your page has a header, a nav, some static copy, and one slow product query, and the user stares at a blank tab until that query returns. The browser cannot paint anything or start fetching your CSS and fonts, because the first byte has not arrived.
Streaming fixes the timing, not the total work. You send the parts you already have immediately and flush the slow parts as they resolve. The browser gets to work early, parsing markup, kicking off resource requests and painting the layout while your data is still in flight. Perceived speed improves even when the full page takes the same wall-clock time to finish.
How the wire actually works
Underneath, on HTTP/1.1 this is chunked transfer encoding, a feature that has been around forever; HTTP/2 and later disallow the Transfer-Encoding header and stream with their own framing. Either way, the server declares no fixed Content-Length and writes the body in pieces. In modern runtimes you express that with a ReadableStream handed straight to a Response:
// app/stream-demo.js
export default function handler(request) {
const stream = new ReadableStream({
start(controller) {
controller.enqueue(new TextEncoder().encode('<!doctype html><body>'));
controller.enqueue(new TextEncoder().encode('<h1>Shell</h1>'));
controller.close();
},
});
return new Response(stream, {
headers: { 'content-type': 'text/html; charset=utf-8' },
});
}
That is the raw mechanism. You rarely write it by hand, because React does the enqueueing for you.
renderToReadableStream and Suspense
React renders to a Web ReadableStream directly with renderToReadableStream. It is the Web Streams variant of the server renderer, which is why Workers-style runtimes can run it with no Node streams; on Node.js itself, react.dev points you at renderToPipeableStream instead.
// server/render.js
import { renderToReadableStream } from 'react-dom/server';
export default async function handler(request) {
const stream = await renderToReadableStream(<App />, {
bootstrapScripts: ['/main.js'],
onError(error) {
console.error(error);
},
});
return new Response(stream, {
headers: { 'content-type': 'text/html; charset=utf-8' },
});
}
The promise resolves once the shell has rendered. The interesting part is what happens with Suspense. Any subtree wrapped in a boundary gets rendered as a fallback in the first flush, then React streams the real markup later with a tiny inline script that swaps the fallback for the resolved content:
// app/product/page.jsx
function Page() {
return (
<Layout>
<Header />
<Suspense fallback={<ProductSkeleton />}>
<ProductDetails id={productId} />
</Suspense>
</Layout>
);
}
Header and Layout ship right away. ProductDetails, which awaits your slow query, shows the skeleton first and gets patched in when the data lands. No client round-trip, no loading-spinner state machine you wrote yourself. React Server Components extend the same idea past HTML: the RSC payload is itself a stream of serialized component output, so a Server Component that awaits data flushes its result into the stream as it resolves rather than blocking the render.
The shell-then-fill pattern
The mental model worth keeping: your page has a shell (nav, layout, anything with no async data dependency) and holes (the Suspense boundaries). Ship the shell in the first chunk so the browser starts painting and loading assets. Let each hole fill on its own timeline. Put your boundaries where a slow data source lives, not around the whole page: one boundary wrapping everything gives you buffered rendering with extra steps.
Running it at the edge
This pairs well with edge functions because the Web Streams API is native to those runtimes. Cloudflare Workers give you ReadableStream, Response and TextEncoder out of the box, the exact primitives renderToReadableStream needs, so the shell leaves a location close to the user instead of a single origin region. That is most of the TTFB win.
One change matters if you are on Next.js. As of Next.js 16.4 (October 2026), export const runtime = 'edge' is deprecated: the docs tell you to remove the export, and Cache Components does not support the runtime option at all. The App Router still streams on the default Node.js runtime with loading.js and Suspense, so on Next.js you get streaming without an edge runtime and put the shell near users through caching instead. If your static shell is cacheable, pushing it through a CDN gets you most of the same latency.
Gotchas that will bite you
Buffering proxies. A CDN or reverse proxy that buffers the whole response before forwarding silently converts your stream back into a blocking response. Nginx buffers proxied responses by default (proxy_buffering on), so set proxy_buffering off for streamed routes or send X-Accel-Buffering: no from the app. Test through your real edge path, not just localhost: the failure is invisible in markup and only shows up in timing.
Headers are locked after the first byte. Once the shell flushes, the status code and response headers are sent. React's docs are explicit: once you start streaming, you can no longer set the response status code. If a Suspense boundary throws late, React keeps rendering, reports it through onError and lets the client recover, but the response is already a 200. Do your auth checks and redirects before the first flush.
Data still has to be near the edge. Streaming hides latency; it does not delete it. If your Suspense boundary awaits a database 200 ms away, that hole takes 200 ms to fill no matter how fast the shell shipped. Keep the data the edge needs close (read replicas, edge KV, cached reads), or you have moved the render close and left the slow part far away.
Mid-stream errors need boundaries. An unhandled throw after the shell cannot fail the whole request cleanly. Wrap risky subtrees in their own Suspense (and an error boundary) so one slow product query dying does not poison the rest of the page.
Questions people ask
Does streaming SSR improve TTFB?
Yes, because the first byte goes out as soon as the shell renders instead of after the slowest data fetch. Total render time stays the same, but the browser starts parsing HTML, fetching CSS and fonts, and painting layout earlier. The gain disappears if a proxy between server and user buffers the full response, so measure TTFB through your real CDN path rather than on localhost.
Can you change the HTTP status code after streaming starts?
No. Status and headers go out with the first chunk, so once the shell flushes the response is committed. React's docs say you can set an error status only if the shell itself fails, which rejects the renderToReadableStream promise and lands in your catch block. Do authentication, redirects and not-found checks before rendering, and treat later errors as client-recoverable.
Is the Next.js Edge Runtime deprecated?
Yes. The Next.js docs mark export const runtime = 'edge' as deprecated and tell you to remove the export, since Node.js is the default runtime. With Cache Components enabled, the runtime option is not supported at all. Streaming with Suspense and loading.js still works on the Node.js runtime, so removing the edge export does not cost you streamed rendering.
The call we'd make
Turn on streaming for any route where the shell is cheap and one or two data reads are slow: product pages, dashboards, search results. Put Suspense boundaries around the slow reads specifically, keep that data reachable from wherever you render, and check proxy_buffering on every hop before you trust the numbers. Where a page is fully static or fully dynamic-fast, streaming buys little and adds moving parts. It is a latency tool for pages that are mostly ready and waiting on a little.
Sources
Cite this article
Kiril Urbonas (2026). Streaming SSR at the Edge: RSC and HTML Streaming. DevOpsNess. Updated 2026-10-31. https://www.devopsness.com/blog/streaming-ssr-at-the-edge-rsc-and-html-streaming
[Streaming SSR at the Edge: RSC and HTML Streaming](https://www.devopsness.com/blog/streaming-ssr-at-the-edge-rsc-and-html-streaming) (Kiril Urbonas, DevOpsNess, updated 2026-10-31)
More from Cloud
Explore more articles in this category
.NET 8 Support Ends November 10: The Lambda and Azure Functions Checklist
.NET 8, .NET 9, the Lambda dotnet8 runtime and the Azure Functions in-process model all lose support on November 10, 2026. Inventory commands, the isolated-worker migration and a CI gate.
Google Cloud's europe-west2 Outage: One Zone Lost Power and the Region Stalled for 6 Hours
On October 20, 2026, europe-west2-b lost power when its generators never started. Cross-zone control-plane timeouts then degraded the whole London region. What happened and the gcloud audit to run now.
Lambda Python 3.10 Is Deprecated Today: Find Every Function and Move to 3.13
AWS deprecated the Lambda python3.10 runtime on October 31, 2026. Functions keep running, patches stop. The inventory commands, IaC diffs and AL2023 gotchas for moving to python3.13.
You might have missed
Evergreen posts worth revisiting.