Skip to content

Lesson 6 of 9 · 25m

Streaming, Suspense, and Honest Loading States

Streaming is a latency-shaping tool: send the shell early, stream slow panels independently, and avoid skeleton waterfalls that make fast apps feel broken.

Streaming is often sold as "show a spinner sooner." That undersells it. The real win is shaping time: the user receives the stable shell immediately, then independent sections resolve as their data arrives. Used well, a slow inventory service does not hold navigation, copy, pricing, or the rest of the page hostage.

Used badly, streaming creates a disco of skeletons. Everything flashes, layout jumps, and the first useful interaction happens later than it would have in a plain server-rendered page.

Route-level loading is the coarse boundary

app/account/
  loading.tsx
  page.tsx

loading.tsx wraps the page in a Suspense boundary automatically. It is a good default for expensive route transitions because the shell can render while the page segment resolves. But it is coarse: the whole page is either ready or replaced by fallback.

export default function Loading() {
  return <div className="panel h-96 animate-pulse" aria-label="Loading account" />;
}

Give the fallback real dimensions. A zero-height skeleton that expands to a full page is cumulative layout shift dressed as polish.

Component-level boundaries localize delay

import { Suspense } from "react";

export default function DashboardPage() {
  return (
    <main>
      <Header />
      <Suspense fallback={<RevenueSkeleton />}>
        <RevenuePanel />
      </Suspense>
      <Suspense fallback={<AuditSkeleton />}>
        <AuditLogPanel />
      </Suspense>
    </main>
  );
}

Now the slow audit export does not delay revenue. More importantly, a failure or timeout in one panel can be isolated with a nearby error boundary.

Do not wrap cheap content in Suspense

Every boundary has a rendering and complexity cost. If the query is usually 5 milliseconds on the same network as the server, a separate skeleton is noise. Stream the slow thing, not everything.

The rule of thumb I give teams: one purposeful fallback per user-perceivable region. Navigation, hero, primary content, then expensive secondary panels. If your screen looks like a skeleton factory, you have built a loading page rather than a page.

Streaming does not remove blocking work

An async server component can still hold up its own boundary. Moving await verySlowReport() under Suspense does not make the query fast; it lets the rest of the page arrive first. You still need timeouts, pagination, indexes, and caching.

Use AbortController with explicit upstream timeouts; cancellation cleanup belongs in finally.

Field notes

  • Avoid unlabeled spinners (aria-busy or visible loading text), and design partial failure because a streamed chunk can error after bytes were sent.
  • Measure first contentful paint, largest contentful paint, and time to first interaction separately. Streaming can improve one while harming another through layout shift.

Was this lesson helpful?

Sign in to rate