In an interview for a senior front-end role, I was asked what streaming in React was. The question looks simple, and that is exactly why it trips people up. The word "streaming" brings along Netflix, ChatGPT typing letter by letter, the WebSocket behind a stock ticker. Whoever answers too fast ends up talking about one of those, and not about what the interviewer asked.
This article is the answer I wish I had given, more calmly: what HTML streaming is, why it exists, how React and Next.js do it today, where it breaks in production and how to tell it apart from the other things that are also called streaming.
First, Which Streaming Are We Talking About
The word is the same, but they are four different things. What they share is that data arrives bit by bit and the receiver starts using it before the end. From there on, almost everything changes.
| HTML in React (SSR) | Video and audio | Real-time data | AI response | |
|---|---|---|---|---|
| What arrives | HTML chunks | Media segments | Messages | Text chunks (tokens) |
| How it arrives | A single HTTP response | Many requests, one per segment | WebSocket or SSE, open connection | Almost always SSE |
| Does it end? | Yes, when the page is done | Recorded video yes, live no | Stays open | Yes, when the model stops |
| Adapts to the network? | No | Yes, switches quality | No | No |
Video is the most different one. When you watch a movie, the player downloads clips of a few seconds in separate files and picks the quality of each one based on what your connection can handle. The standards are HLS, created by Apple, and DASH, which the browser consumes through the Media Source Extensions APIContract that defines how one program asks another for data or actions: which endpoints to call, what to send and what comes back. On the web, usually HTTP with JSON. (MDN). React streaming has none of that: it is a regular HTTP response that takes a while to finish and keeps delivering HTML in the meantime.

WebSocket and SSE (Server-Sent Events) are another family: connections that stay open so the server can send events whenever it wants. WebSocket goes both ways; SSE only goes from the server to the browser (MDN). SSE is what makes an AI assistant's text show up bit by bit on the screen.
In the interview, separating these four in one sentence already shows you know what you are talking about. The rest of the article is about the first one.
The Problem Streaming Solves
Before React 18, server rendering followed a rigid order. Dan Abramov, from the React team, summed it up in three sentences when he presented the new architecture in June 2021: you have to fetch everything before you can show anything, load everything before you can hydrate anything, and hydrate everything before you can interact with anything (React 18 Working Group).
In practice, if a product page has the title, the price and a reviews section that depends on a slow query, the user stares at a blank screen until the reviews arrive. The fast part is held hostage by the slowest one.

The idea behind streaming is that of a good restaurant: the starter comes out as soon as it is ready, and the main course arrives later, without anyone staring at an empty table. The server immediately sends the page skeleton with the title and the price, and a "loading" in place of the reviews. When the query finishes, the rest of the HTML arrives in the same response, along with a small script that slots the content into the right place.
The second half of the solution happens in the browser and is called selective hydration. Instead of turning the whole page into React at once, React hydrates it piece by piece, and gives priority to the piece the user clicked on. A button at the top already responds while the section below is still arriving.
How React Does It
The central piece is <Suspense>. It marks a boundary: everything inside it can arrive later, and in the meantime the fallback shows up. The documentation says exactly that: with any streaming rendering API, React first sends the skeleton with the fallbacks and then the HTML of each boundary, replacing the fallback when the content arrives (React).
On a Node server, the function is renderToPipeableStream. It returns the HTML bit by bit and notifies you at different moments:
import { createServer } from 'node:http';
import { renderToPipeableStream } from 'react-dom/server';
import App from './App.js';
createServer((req, res) => {
let deuErro = false;
const { pipe, abort } = renderToPipeableStream(<App />, {
bootstrapScripts: ['/main.js'],
onShellReady() {
// The skeleton is ready. From here on, status and headers are fixed.
res.statusCode = deuErro ? 500 : 200;
res.setHeader('content-type', 'text/html');
pipe(res);
},
onShellError() {
// Nothing has gone out yet: you can still respond 500 with an error page.
res.statusCode = 500;
res.setHeader('content-type', 'text/html');
res.end('<h1>Something went wrong</h1>');
},
onError(erro) {
deuErro = true;
console.error(erro);
},
});
// If it takes too long, React sends the fallbacks and finishes in the browser.
setTimeout(() => abort(), 10_000);
}).listen(3000);The callback names already tell the story. onShellReady is the moment to start sending to the user. There is also onAllReady, which waits for the whole page, and the documentation suggests using it for search crawlers, which prefer to receive the complete HTML (React). In environments that use Web Streams, like Deno and edge, the equivalent function is renderToReadableStream. On Node, React itself recommends sticking with the Node Streams version, because the other one does not compress by default and ends up losing the benefit (React 19.2).
A detail that tends to come up in interviews: Suspense does not notice data fetched inside a useEffect. It only kicks in with lazy components, with use() receiving a Promise, or with frameworks that integrate with it. If you fetch data in an effect, you get no streaming at all.
In Next.js, You Barely Write Any of This
If you use the Next.js App Router, you already have streaming without calling renderToPipeableStream: the framework does it for you. Your job is to decide where to put the boundaries.
// app/produtos/[id]/page.tsx
import { Suspense } from 'react';
async function Avaliacoes({ id }: { id: string }) {
const res = await fetch(`https://api.exemplo.com/produtos/${id}/avaliacoes`);
const avaliacoes: { id: string; texto: string }[] = await res.json();
return (
<ul>
{avaliacoes.map((a) => (
<li key={a.id}>{a.texto}</li>
))}
</ul>
);
}
export default async function Pagina({ params }: { params: Promise<{ id: string }> }) {
const { id } = await params;
return (
<>
<h1>Product {id}</h1>
<Suspense fallback={<p>Loading reviews...</p>}>
<Avaliacoes id={id} />
</Suspense>
</>
);
}The title goes out in the first chunk; the reviews arrive when the API responds. The loading.js file does the same thing for the whole page of a route segment, wrapping everything in an automatic Suspense (Next.js).
Under the hood, Next.js sends two streams together: the HTML and the Server Components payload, which React uses to build the tree in the browser. When navigating between pages, only the payload travels, and no HTML is downloaded again (Next.js). If you want to look at that format up close, Dan Abramov explains it in Progressive JSON, the best piece I know on the subject. To play with a sample project without installing anything, StackBlitz runs Next.js in the browser.
Since Next.js 16, from October 2025, there is also Partial Prerendering, turned on by the cacheComponents option. The static part of the page becomes a ready-made skeleton, served from a CDN like a static site, and only the dynamic holes are filled in via streaming (Next.js 16). React 19.2 brought the same idea to React itself, with the prerender and resume functions. It is the combination of SSGStrategy that generates page HTML once, at build time, and serves the ready files. Very fast, but content only changes with a new build. and streaming that frameworks had been chasing for years.
Cache and Streaming: What Goes Into the Shell and What Arrives Later
With cacheComponents turned on, caching is no longer a separate topic from streaming. The question becomes: can this piece of the page be reused across visitors? If it can, it goes into the static shell. If it cannot, it has to sit inside a <Suspense> and arrive later, streamed. The documentation describes exactly that: a result marked with use cache goes into the shell, as long as it does not expire too quickly, and so does the Suspense fallback, while the dynamic content arrives at request time (Next.js).
Back to the product page: reviews do not change every second. You can keep them for a few hours and tag the cache with the product:
// app/produtos/[id]/avaliacoes.tsx
import { cacheLife, cacheTag } from 'next/cache';
export async function Avaliacoes({ id }: { id: string }) {
'use cache';
cacheLife('hours');
cacheTag(`avaliacoes-${id}`);
const res = await fetch(`https://api.exemplo.com/produtos/${id}/avaliacoes`);
const avaliacoes: { id: string; texto: string }[] = await res.json();
return <ul>{avaliacoes.map((a) => <li key={a.id}>{a.texto}</li>)}</ul>;
}cacheLife says how long the result is valid. There are built-in profiles, from seconds to max, and you can define your own in next.config (Next.js). A detail few people know: a cache with a very short life (revalidating every few seconds or expiring in under five minutes) does not go into the shell and becomes one more dynamic hole, filled by streaming. Choosing the profile is choosing what the user sees first.
Creating the cache is the easy part. The hard part is knowing when to throw it away, and Next.js has two functions for that, with different behavior:
'use server';
import { updateTag } from 'next/cache';
export async function publicarAvaliacao(id: string, texto: string) {
await salvarAvaliacao(id, texto);
// Whoever just wrote needs to see their own review on the next load.
updateTag(`avaliacoes-${id}`);
}updateTag only works inside a Server Action and makes the next request wait for fresh data: it is the case of someone who wrote something and wants to see it right away (Next.js). revalidateTag(tag, 'max') covers the rest, like a CMS webhookHTTP call a system makes to your address when something happens, like an approved payment, notifying you right away instead of you polling for changes. in a Route Handler: the next visitor still gets the old version while the new one is generated in the background. Since Next.js 16 the second argument is expected; the single-argument form is deprecated (Next.js). revalidatePath still exists to invalidate a whole route.
Two rules avoid most of the trouble. The first is to tag the lists too: if the review shows up on the product page and on the category listing, both need the same tag, or one of them goes stale. The second is never to put user data in a plain use cache, which is shared with everyone. For what depends on a cookie or header there is use cache: private, and for a cache shared across several server instances there is use cache: remote, which stores it in Redis or a similar service.
What Changes in the Metrics
The most visible gain is in the first byte and the first paint. Without streaming, the time to first byte equals the time of the slowest query. With streaming, the first paint is decoupled from data fetching time (Next.js). On interaction, each Suspense boundary becomes a unit of hydration, which eases INPCore Web Vitals metric that measures how long the page takes to visually react to clicks, taps and key presses during a visit..
But you can make LCPCore Web Vitals metric that measures how long the largest visible element on screen, usually an image or heading, takes to appear. worse without noticing. If the largest element on the page, usually the main image or the title, is inside a Suspense boundary, it only shows up when the boundary resolves. The recommendation is to keep the LCP element outside Suspense, in the skeleton. And a fallback whose size differs from the final content makes the page jump, which hurts CLSCore Web Vitals metric that measures how much content jumps around while the page loads, like a button that moves down when an image appears.. patterns.dev sums up the risk well: TTFB looks better than the real experience, so track LCP and INP, not just the first byte (patterns.dev). I explained each of these metrics in Core Web Vitals and the Lighthouse score.
Where Streaming Breaks in Production
This is the part that separates those who read the documentation from those who have actually shipped it.
The status code gets stuck. The response starts with 200. If a component inside Suspense finds out the product does not exist, you can no longer return 404. Next.js works around it with a <meta name="robots" content="noindex"> and a redirect in the browser, but for crawlers the page responded 200 (Next.js). The way out is to check whatever can return 404 before the first boundary.
An error in the middle does not take the page down. React looks for the nearest Suspense, sends the fallback in the HTML and tries again in the browser. If it fails again, the Error Boundary steps in. That is good for the user and bad for monitoring, if nobody is watching onError.
Someone along the way collects everything. Nginx buffers the response by default, and the Next.js documentation says to send the X-Accel-Buffering: no header. CDNs can do the same, AWS Lambda requires an explicit streaming response mode, and Gzip or Brotli compression can hold chunks back before sending. Even curl fools you: without the -N option, it also waits for everything.
To check whether it is working, the browser's Network tab is enough: the first byte arrives early and the document download time is long. If the first byte is slow and the download is instant, something along the way is collecting the response.
What About Streaming AI Responses?
This is where the two ideas meet. An AI chat in React uses SSE to receive the text bit by bit, and the Vercel AI SDK has become the most common path: streamText on the server and the useChat hook on the client. Under the hood, the default protocol of useChat is SSE (AI SDK).
The same SDK has a module that streams ready-made React components instead of text, called AI SDK RSC. The idea is neat: the model decides and the server sends an already rendered weather card. But the page itself warns that it is experimental and recommends AI SDK UI for production (AI SDK). I would follow that advice. And the useChat API has changed a lot between versions: any tutorial with handleSubmit and input coming out of the hook is already outdated.
The Questions That Come Up in the Interview
If I were the interviewer, I would follow this path, and it is good to have a short answer for each step.
What is streaming SSR? It is sending the HTML in chunks in the same response: the skeleton first and the content of each Suspense later, with a script that swaps the fallback. How does it relate to Suspense? Suspense is the boundary for streaming and hydration; without a boundary, nothing goes out before the whole tree is ready. What is the difference between onShellReady and onAllReady? The first is for people, the second for crawlers and static generation. What happens with an error after the stream has started? The status has already gone out as 200; the error falls back to the nearest fallback and React tries again in the browser.
Then come the questions from people who have suffered through it: why streaming does not work behind my Nginx, why useEffect does not trigger Suspense, how to measure whether it is working, how to invalidate the cache when a new review comes in without serving the old version to the person who just wrote it. If you answered the ones in the previous paragraph and also talk about buffering and LCP inside Suspense, the conversation moves up a level. Whether React is still worth studying is something I discussed in is React still worth learning in 2026.
Frequently Asked Questions
What is streaming in React?
It is sending the page HTML in parts, in the same HTTP response. React first sends the skeleton with the loading states and then the content of each Suspense boundary, as soon as it is ready.
What is the difference between streaming SSR and video streaming?
Video uses protocols like HLS and DASH, downloads many separate segments and adjusts quality to the network. Streaming SSR is a single HTTP response that delivers HTML bit by bit, with no quality adaptation.
Is streaming SSR the same as SSE or WebSocket?
No. SSE and WebSocket keep a connection open to send events at any time. Streaming SSR is a response that starts, delivers the HTML in chunks and ends.
How does Suspense enable streaming in Next.js?
In the App Router, each <Suspense> or loading.js file creates a boundary. Next.js sends what is outside it in the first chunk and what is inside it when the data arrives.
Does streaming hurt SEO?
No, according to the Next.js documentation: crawlers receive the complete HTML. The thing to watch is the status code, which stays 200 even when the page discovers a 404 halfway through.
How do caching and streaming work together in Next.js?
With cacheComponents on, whatever has use cache goes into the static shell and whatever is dynamic stays inside a <Suspense>, arriving later by streaming. To invalidate, use updateTag in a Server Action when the writer needs to see the change right away, and revalidateTag(tag, 'max') for everything else.
Why does my page return 200 when it should be 404?
Because the status goes out with the first byte. Run the check that can return 404 before the first Suspense boundary, or in a middleware.
Why does streaming not work behind Nginx or a CDN?
Because they buffer the response and deliver everything at once. In Nginx, the X-Accel-Buffering: no header fixes it; with a CDN, you need to check whether it supports streaming responses.
renderToPipeableStream or renderToReadableStream?
On Node, renderToPipeableStream, which is what React recommends. On Deno, Bun or edge, which use Web Streams, renderToReadableStream.
References
- React. Suspense, renderToPipeableStream, React 19 (2024), React 19.2 (2025) and React 19.3 (2026).
- Abramov, D. New Suspense SSR Architecture in React 18 (2021) and Progressive JSON (2025).
- Next.js. Streaming, loading.js, Caching, cacheLife, revalidateTag, updateTag and Next.js 16 (2025).
- MDN. Streams API, Transfer-Encoding, Server-sent events, WebSockets and Media Source Extensions.
- IETF. RFC 9112, HTTP/1.1 (2022).
- web.dev. Time to First Byte and Rendering on the Web.
- patterns.dev. Streaming SSR.
- Vercel. AI SDK: stream protocol and AI SDK RSC.
- Hallie, L. and Osmani, A. Learning Patterns. Leanpub (free).