🎯 <Suspense> β€” Defer Rendering Until Ready

Wraps components that may suspend, showing a fallback UI while waiting.


βœ… Basic Syntax

<Suspense fallback={<p>Loading...</p>}>
  <SomeComponent />
</Suspense>


βœ… Use Cases

Feature Suspends? Requires <Suspense>?
React.lazy() βœ… Yes βœ… Yes
use(promise) βœ… Yes βœ… Yes
use(context) ❌ No ❌ No
SSR/RSC + async βœ… Yes βœ… (Client hydration)

βœ… Example: Lazy-loaded Component

const Chart = lazy(() => import('./Chart'));

function Page() {
  return (
    <Suspense fallback={<p>Loading chart...</p>}>
      <Chart />
    </Suspense>
  );
}


βœ… Example: Streaming async data with use()

function Message({ promise }) {
  const data = use(promise);
  return <p>{data}</p>;
}

<Suspense fallback={<p>Loading message...</p>}>
  <Message promise={fetchMessage()} />
</Suspense>


βœ… Can Be Nested

<Suspense fallback={<Spinner />}>
  <ComponentA />
  <Suspense fallback={<Skeleton />}>
    <ComponentB />
  </Suspense>
</Suspense>

Each nested <Suspense> handles its own loading boundaries independently.