IT lexicon › Web › React Suspense

React Suspense

Web På svenska → Updated: 2026-05-27

React feature: declarative loading state. <Suspense fallback={<Spinner />}><DataComponent /></Suspense>. Child can "suspend" by throwing a Promise — Suspense shows fallback until resolved. Stable in React 18.

Use cases: lazy-loaded routes (React.lazy()), data fetching (with libraries like Relay, SWR, TanStack Query), Server Components streaming. Suspense boundaries: nested boundaries — outer suspense shows overall, inner can stream individual sections. Selective hydration: server streams HTML, client hydrates components by priority (visible-first). Migration friction: legacy data fetching (useEffect + setState) not Suspense-aware → manual wrapping. Competitor: Vue suspense, Solid resources, Svelte await blocks — all have equivalent pattern.

← Back to the lexicon