Rendering strategies · senior
Streaming with loading.tsx and Suspense
Streaming sends the page shell first and each Suspense boundary's content later in the same response; loading.tsx is a route-level Suspense boundary, and pushing slow or request-time work down into small boundaries keeps the rest of the page fast.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
loading.tsxautomatically wraps the segment's page in<Suspense>; inline<Suspense>lets you place boundaries anywhere.- A top-level
awaitoncookies(),headers()or a session check in a layout delays the first streamed chunk and holds{children}behind it. Move it into a small component (like<UserMenu>) inside Suspense. - Start fetches in parallel and pass promises down so boundaries resolve independently.
- Fallbacks should reserve space (skeletons with fixed size) to avoid CLS.
- The HTTP status is sent with the shell; call
notFound()/redirect()before streaming starts where possible. - Dynamic pages stream metadata after the shell; bots that need metadata in
<head>(detected by user agent, configurable withhtmlLimitedBots) get a blocking render. - Self-hosting: proxies must not buffer (
X-Accel-Buffering: nofor nginx), otherwise the shell and content arrive together and PPR loses its benefit. - With Partial Prefetching, loading shells are prefetched so clicks show UI instantly.
The red pen
Common traps: mistake → fix
Mistake: "One
loading.tsxat the root is enough"Fix: the whole page shows one spinner; place boundaries around slow parts.
Mistake: "Streaming needs WebSockets"
Fix: it is one HTTP response sent in chunks.
Mistake: "
notFound()deep in a streamed boundary still returns 404"Fix: the status may already be committed.
Easy to hard
Questions interviewers ask, easy to hard
- How does streaming work in the App Router?
- What is the difference between
loading.tsxand an inline<Suspense>? - Our dashboard header awaits the session and the whole page waits. Fix it.
- What happens to status codes once streaming has started?
- Why does streaming not work behind our nginx?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.