Next.js Developer interview question · Most asked
How does streaming with Suspense work in Next.js?
Summary
The server sends HTML in chunks: the shell (layout plus fast parts) is sent immediately, and slower components wrapped in <Suspense fallback={...}> stream in when their data resolves, without blocking the whole page.
Longer Answer
loading.tsx automatically wraps a page in Suspense. Place Suspense boundaries around slow, independent sections (recommendations, comments) to improve Time To First Byte and First Contentful Paint. Streaming works with SSR; SEO still gets the full HTML, since crawlers receive the completed stream.
Code Example
import { Suspense } from "react";
export default function ProductPage({ params }: { params: Promise<{ id: string }> }) {
return (
<>
<ProductDetails params={params} />
<Suspense fallback={<p>Loading reviews…</p>}>
<Reviews params={params} /> {/* slow async server component */}
</Suspense>
</>
);
}
Key Points
- Shell first, slow parts stream later
loading.tsx= route-level Suspense- Granular
<Suspense>boundaries - Improves TTFB/FCP
More most-asked Next.js Developer questions
- How does data fetching work in the App Router?
- How did caching defaults change in Next.js 15?
- What happens, step by step, when a request reaches a Next.js App Router application?
- What is Next.js and what problems does it solve on top of React?
- What are the differences between the App Router and the Pages Router?
- What is the difference between Server Components and Client Components?
- Explain the App Router file conventions: page, layout, loading, error, not-found, template and route.
- Explain SSR, SSG, ISR and CSR in Next.js.