How do you handle streaming and suspense in App Router?
Assesses fundamental understanding of Next.js conventions, runtime behavior, and memory/performance considerations.
Hiring managers look for precision, avoidance of ambiguous jargon, and ability to explain trade-offs under real production conditions.
The App Router has built-in support for streaming and React Suspense, allowing you to progressively render and stream UI to the client.
// app/page.js
import { Suspense } from "react";
async function UserProfile({ userId }) {
const user = await getUserData(userId); // This can be slow
return <div>Welcome, {user.name}!</div>;
}
async function UserPosts({ userId }) {
const posts = await getUserPosts(userId); // This can also be slow
return (
<div>
{posts.map((post) => (
<div key={post.id}>{post.title}</div>
))}
</div>
);
}
export default function Page({ params }) {
return (
<div>
<h1>User Dashboard</h1>
<Suspense fallback={<div>Loading profile...</div>}>
<UserProfile userId={params.id} />
</Suspense>
<Suspense fallback={<div>Loading posts...</div>}>
<UserPosts userId={params.id} />
</Suspense>
</div>
);
}
Benefits of streaming:
- Faster initial page load
- Better perceived performance
- Progressive enhancement
- SEO-friendly as search engines can index content as it streams
Candidate Response Strategy & Interview Tips
- Start with a concise one-sentence summary: Deliver a direct, confident answer first before expanding into nuances.
- Demonstrate real-world trade-offs: Discuss where this approach excels and when you would avoid it in production systems.
- Discuss complexity & edge cases: Proactively explain time/space complexity or boundary conditions (null values, scale limits).
- Prepare for interviewer follow-ups: Technical hiring panels frequently probe deeper into concurrency, backward compatibility, or alternative libraries.