Dependent client-side fetches

data/client-fetch-waterfallwarningperformancereact

Why it matters

A SWR/React Query hook whose key or enabled waits for another hook's data starts only after the first request finishes, and both start only after hydration: two serial round trips before the content shows.

Fix

Fetch on the server and pass the data down, or serve both from one endpoint.

Credit

  • From Vercel

    SWR documents conditional and dependent fetching, where a request waits for the previous one's data.

  • From TanStack

    TanStack Query documents dependent queries that run serially.

References

See it