Capítulo 78 de 80

Chapter 78: usePrefetchInfiniteQuery

Core Idea

The infinite-query counterpart to usePrefetchQuery — same "call before the boundary" placement rule, extended with the infinite-query-required options.

Key Concepts

  • Options: everything queryClient.infiniteQuery() accepts; queryKey, queryFn (unless defaulted), initialPageParam, and getNextPageParam are all required.
  • Returns nothing: same side-effect-only shape as usePrefetchQuery.
  • Placement: same rule — call above the <Suspense> boundary wrapping the component that calls useSuspenseInfiniteQuery.

Key Takeaways

  1. Reach for this specifically when the eventual consumer will use useSuspenseInfiniteQuery, not useSuspenseQuery — the required infinite-query options make this hook distinct, not just a rename.

Connects To

  • usePrefetchQuery: the non-infinite counterpart with identical placement rules.
  • useSuspenseInfiniteQuery: the eventual consumer this hook prefetches for.