How do you stream data with Suspense boundaries?

Split the page into components that fetch their own data and wrap each slow one in <Suspense>. Next.js sends the static parts and fallbacks right away, then streams each component's HTML and RSC data over the same HTTP response as it resolves, with no extra requests.

Mechanics

  1. The server renders until it hits suspended components and sends the HTML with fallbacks (the shell).
  2. The connection stays open. When a component's data resolves, React sends a chunk containing its HTML and a small inline script that swaps it into the fallback's place.
  3. The RSC payload streams in parallel, so client navigation uses the same data.
  4. React hydrates each piece as it arrives (selective hydration).

Design rules

  • Start work early, await late. Kick off fetches in parallel; awaiting one after another in a parent creates a waterfall that streaming cannot fix.
  • Push awaits down. Pass the params promise or a data promise into child components instead of awaiting at the top.
  • Granularity: one boundary per independent region. Too many tiny boundaries cause popcorn-like loading; too few delay everything.
  • Promise to client: pass an unresolved promise to a Client Component and read it with use() inside its own boundary.

Status codes and SEO

Once streaming starts, the status is already 200. Call notFound() or redirect() before the first boundary when you need correct status codes. Next.js detects bots that cannot handle streamed metadata (htmlLimitedBots) and renders the full page for them.

Infrastructure

Streaming needs a host that does not buffer responses. Some proxies (nginx with buffering on) break it; set X-Accel-Buffering: no or disable buffering. Next.js 16.3 switched App Router SSR to native Node.js streams for higher throughput.

Code example

tsx
1// app/orders/page.tsx
2import { Suspense } from "react";
3import { OrdersTable } from "./orders-table"; // "use client", reads the promise with use()
4import { getOrders, getSummary } from "@/lib/orders";
5
6async function Summary({ summaryPromise }: { summaryPromise: ReturnType<typeof getSummary> }) {
7 const s = await summaryPromise;
8 return <p>{s.count} orders, ${s.total} total</p>;
9}
10
11export default function OrdersPage() {
12 // Start both requests immediately, in parallel
13 const summaryPromise = getSummary();
14 const ordersPromise = getOrders();
15
16 return (
17 <main>
18 <h1>Orders</h1>
19 <Suspense fallback={<p>Calculating totals…</p>}>
20 <Summary summaryPromise={summaryPromise} />
21 </Suspense>
22 <Suspense fallback={<p>Loading orders…</p>}>
23 <OrdersTable ordersPromise={ordersPromise} />
24 </Suspense>
25 </main>
26 );
27}

Practice this question

Open it in the study app to track progress, take notes, listen to the answer and work through the rest of the Next.js set.

Open in study app