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β
16 - **Required**
17 - The query key to prefetch during render
18β
19- `queryFn: (context: QueryFunctionContext) => Promise<TData>`
20β
21 - **Required, but only if no default query function has been defined** See [Default Query Function](../guides/default-query-function.md) for more information.
22β
23- `initialPageParam: TPageParam`
24β
25 - **Required**
26 - The default page param to use when fetching the first page.
27β
28- `getNextPageParam: (lastPage, allPages, lastPageParam, allPageParams) => TPageParam | undefined | null`
29β
30 - **Required**
31 - 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.
32 - It should return a **single variable** that will be passed as the last optional parameter to your query function.
33 - Return `undefined` or `null` to indicate there is no next page available.
34β
35- **Returns**
36β
37The `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`](../reference/useSuspenseInfiniteQuery.md)