Course contentsShow
← React
Lesson 1383 of 2,39634. Suspense FundamentalsFree lesson

Suspense Boundary Placement Patterns

Common patterns: route-level, feature-level, and component-level boundaries for different use cases.

Suspense Boundary Placement Patterns

What you'll learn: The three main architectural patterns for placing Suspense boundaries in your application.

The Three Strategic Patterns

Just as Error Boundaries have placement strategies, Suspense boundaries follow common architectural patterns based on what they're protecting.

Route-Level Boundaries

Place a <Suspense> boundary around entire route components. When navigating between pages, the whole page shows a loading state. This creates a clear mental model: "I'm loading a new page." Perfect for traditional multi-page-feel applications.

<Route path="/dashboard" element={
  <Suspense fallback={<PageSpinner />}>
    <DashboardPage />
  </Suspense>
} />

Feature-Level Boundaries

Wrap individual features or major sections of a page. This lets the shell of your UI render immediately while heavy features load independently. Think of a dashboard where the header renders instantly but charts suspend individually.

<Suspense fallback={<ChartSkeleton />}>
  <AnalyticsChart />
</Suspense>

<Suspense fallback={<TableSkeleton />}>
  <UserTable />
</Suspense>

Component-Level Boundaries

The most granular approach—wrap individual small components that fetch data. Use sparingly, as too many tiny boundaries create visual noise with multiple loading states popping in and out.

<Suspense fallback={<AvatarSkeleton />}>
  <UserAvatar userId={id} />
</Suspense>

Choosing Your Pattern

Route-level works for simple navigation flows. Feature-level balances progressive loading with user experience—it's often the sweet spot. Component-level is for truly independent widgets that don't distract when loading separately.

Mix patterns as needed. Your header might use component-level for a user avatar, while the main content uses feature-level boundaries.

Key Takeaway: Choose route-level for page transitions, feature-level for independent sections of a page, and component-level sparingly for truly isolated widgets—match your boundary granularity to your user experience goals.