← All topics

Data fetching & streaming

Fetch in async Server Components, and wrap slow parts in Suspense so the rest of the page paints immediately.

  • Start fetches as high as is useful, await them where they are needed.
  • react's cache() dedupes identical calls within a single render (generateMetadata + page + layout).
  • Suspense boundaries stream: the shell is sent first, slow sections replace their fallbacks when ready.
  • Give Suspense a key tied to search params to re-show the fallback when filters change.

See it in this app: src/app/(app)/projects/page.tsx (stats and grid stream independently)

<Suspense fallback={<StatsSkeleton />}>
  <Stats />
</Suspense>
<Suspense fallback={<GridSkeleton />}>
  <ProjectGrid />
</Suspense>