Streaming Demo

A companion app for the Next.js Streaming guide. Each route isolates a single streaming concept so you can see it in action — chunks arrive progressively, fallbacks flash yellow as they're replaced, and hydration differences are visible in DevTools.

Demos

RouteWhat it demonstrates
/loading-demoPage-level streaming with loading.tsx — skeleton appears instantly, content streams in after ~2s
/suspense-demoGranular streaming with sibling <Suspense> boundaries that resolve independently (1s and 3s)
/hydration-singleThree heavy client components hydrate in a single blocking pass — buttons are unresponsive until all three finish
/hydration-splitSame components wrapped in <Suspense> — React hydrates them as separate tasks, yielding to the browser between each
/api/html-streamRaw HTML streaming from a Route Handler with early CSS discovery — watch the server logs to see the stylesheet fetched while HTML is still streaming
/api/streamA configurable ReadableStream of plain text — adjust ?chunks, ?size, and ?delay to experiment with browser buffering

Getting started

pnpm install
pnpm dev

Open http://localhost:3000.

What to look for

  • Yellow flash: All streamed content animates with a yellow highlight when it arrives, so you can see exactly when each chunk paints.
  • DevTools Performance tab: Compare /hydration-single (one long task) vs /hydration-split (three shorter tasks with yields).
  • Browser buffering: Visit /api/stream?chunks=10&size=10&delay=200 in Safari — small chunks get buffered. Change to size=1024 and they flush immediately.
  • Server logs: The /api/html-stream route logs each chunk and the CSS request to the terminal, showing the order of events.

Learn more