Suspense Boundary Design

Design React Suspense boundaries interactively. Use when planning loading states, configuring boundary granularity, or combining with ErrorBoundary.

naporin0624 Updated

File contents

Suspense Boundary Design

Interview Questions

  1. Loading units - Which components load independently?
  2. Error handling - Show error UI, retry button, or bubble up?
  3. Loading UI - Skeleton, spinner, or shimmer?

Pattern

import { ErrorBoundary } from 'react-error-boundary';

<ErrorBoundary FallbackComponent={ErrorFallback}>
  <Suspense fallback={<Skeleton />}>
    <AsyncComponent />
  </Suspense>
</ErrorBoundary>

Rule: ErrorBoundary wraps Suspense (outside).

Best Practices

  1. Match skeleton to content size (prevents layout shifts)
  2. Avoid nested Suspense unless intentional waterfall
  3. Group components sharing data under same boundary

Related

naporin0624/claude-plugin-hono-electron/tree/main/skills/suspense-boundary-design commit a41f12d125

Frequently asked questions

npx skillmds@latest add naporin0624/suspense-boundary-design