Open History to see the last commit
1---
2id: usePrefetchInfiniteQuery
3title: usePrefetchInfiniteQuery
4---
5β
6```tsx
7usePrefetchInfiniteQuery(options)
8```
9β
10**Options**
11β
12You can pass everything to `usePrefetchInfiniteQuery` that you can pass to [`queryClient.prefetchInfiniteQuery`](../../../../reference/QueryClient.md#queryclientprefetchinfinitequery). Remember that some of them are required as below:
13β
14- `queryKey: QueryKey`
15 - **Required**
16 - The query key to prefetch during render
17β
18- `queryFn: (context: QueryFunctionContext) => Promise<TData>`
19 - **Required, but only if no default query function has been defined** See [Default Query Function](../../guides/default-query-function.md) for more information.
20β
21- `initialPageParam: TPageParam`
22 - **Required**
23 - The default page param to use when fetching the first page.
24β
25- `getNextPageParam: (lastPage, allPages, lastPageParam, allPageParams) => TPageParam | undefined | null`
26 - **Required**
27 - When new data is received for this query, this function receives both the last page of the infinite list of data and the full array of all pages, as well as pageParam information.
28 - It should return a **single variable** that will be passed as the last optional parameter to your query function.
29 - Return `undefined` or `null` to indicate there is no next page available.
30β
31- **Returns**
32β
33The `usePrefetchInfiniteQuery` does not return anything, it should be used just to fire a prefetch during render, before a suspense boundary that wraps a component that uses [`useSuspenseInfiniteQuery`](../useSuspenseInfiniteQuery.md)