Nextjs Fundamentals · Data Fetching

Streaming with Suspense

`<Suspense>` and the static shell

Streaming with Suspense

A page that fetches data blocks its whole render until every request resolves. Streaming breaks the page into chunks and sends each one as soon as it is ready, so the user sees the shell immediately instead of a blank screen.

Wrap a slow component in <Suspense> with a fallback. Everything outside the boundary renders and streams at once; the content inside streams in when its data settles:

export default function BlogPage() {
  return (
    <div>
      <header>
        <h1>Welcome to the Blog</h1>
      </header>
      <Suspense fallback={<BlogListSkeleton />}>
        <BlogList />
      </Suspense>
    </div>
  );
}

The part of the page that does not depend on uncached data — here the header — is the static shell. Next.js can prerender it ahead of time and serve it instantly, then fill in the streamed holes. That combination is Partial Prerendering: a fast, static shell plus progressively streamed dynamic content.

A loading.tsx file does the same thing for a whole route segment — Next.js automatically nests it in a <Suspense> boundary around the page. But a layout that reads uncached data does not fall back to a same-segment loading.tsx, so placing <Suspense> closer to the uncached access is the recommended, more granular choice.

You are about to answer a short quiz on <Suspense> and the static shell.

  1. Streaming lets a page send parts of the UI as soon as they are ready instead of waiting for every request.
  2. You wrap a slow component in ___ with a fallback so the rest of the page can render first.
  3. The static shell is the part of the page that does not depend on uncached data and can be prerendered.
  4. A fast static shell combined with progressively streamed dynamic content is called ___ Prerendering.
  5. Next.js automatically wraps a page in a Suspense boundary when you add a loading.tsx file.