Suspense
Suspense lets React show a fallback UI while a child is not ready to render — most commonly while waiting on data.
Introduction
Suspense lets React show a fallback UI while a child is not ready to render — most commonly while waiting on data. In React 19, the use(promise) Hook reads a Promise during render; if the Promise is pending, React suspends that component and the nearest <Suspense> boundary shows its fallback.
Beginner analogy: Suspense is a "please wait" placeholder around a seat at the table. The kitchen (async work) finishes, then the real dish replaces the placeholder — without you writing manual loading flags for that subtree.
By the end of this lesson you will wire use + Suspense, place boundaries correctly, and avoid common mistakes.
Understanding the topic
Core concepts:
- Suspense — declare fallback UI for children that suspend.
- use(promise) (React 19) — read a Promise during render; pending Promises suspend.
- Place boundaries close to the slow subtree so the rest of the page stays interactive.
- Frameworks (for example Next.js
loading.tsx) often wrap routes in Suspense for you. - Suspense is not an error boundary — pair with error UI for failures.
- Prefer stable Promises (or a cache) so remounts do not restart the same request endlessly.
Syntax reference
Visual workflow / architecture:
import { Suspense, use } from "react";type Lesson = { title: string };function LessonHeading({ lessonPromise }: { lessonPromise: Promise<Lesson> }) {const lesson = use(lessonPromise); // suspends until resolvedreturn <h1>{lesson.title}</h1>;}export function CourseHero({ lessonPromise }: { lessonPromise: Promise<Lesson> }) {return (<Suspense fallback={<p>Loading lesson…</p>}><LessonHeading lessonPromise={lessonPromise} /></Suspense>);}// Parent starts the Promise once (do not create a new Promise every render):// const lessonPromise = fetchLesson(slug);
Real-world use
Teams use Suspense for route skeletons, deferred panels, and streaming Server Components. With React 19, use(promise) is the small Client-Component pattern for "read this Promise under Suspense." Libraries and frameworks may still own caching and deduplication — Suspense only owns the loading boundary.
Best practices
- Wrap only the subtree that needs the async value — keep headers and nav outside when possible.
- Pass a Promise created above the suspending child (or from a cache), not
use(fetch(...))inline on every render. - Keep fallbacks lightweight and layout-stable to reduce shift.
- Use Error Boundaries (or framework
error.tsx) for rejected Promises. - In Next.js App Router, prefer Server Components +
loading.tsxwhen the data can stay on the server.
Common mistakes
- Creating a new Promise inside the component that calls
useon every render — causes repeated fetches and endless suspense. - Expecting Suspense to catch thrown Errors — it handles pending Promises / lazy loads, not failures.
- Putting one giant Suspense around the whole app — one slow child blanks everything.
- Confusing
usewithuseEffectdata fetching —useintegrates with Suspense; effects do not suspend.
Hands-on exercise
Interview preparation — practice these questions:
- Q1. What does
<Suspense>do when a child suspends? - Q2. How does React 19
use(promise)interact with Suspense? - Q3. Why must the Promise be stable across renders?
- Q4. How is Suspense different from an Error Boundary?
- Q5. When would you use Next.js
loading.tsxinstead of a manual Client Suspense boundary?