Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

InfiniteQueryPageParamsOptions.md

37 lines2.0 KB

1---
2id: InfiniteQueryPageParamsOptions
3title: InfiniteQueryPageParamsOptions
4---
5​
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7​
8Defined in: [packages/query-core/src/types.ts:485](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L485)
9​
10The page param options of an infinite query: `initialPageParam`, and the `getNextPageParam` and
11`getPreviousPageParam` functions that compute the params of the pages around it.
12​
13## Extends
14​
15- [`InitialPageParam`](InitialPageParam.md)\<`TPageParam`\>
16​
17## Extended by
18​
19- [`InfiniteQueryObserverOptions`](InfiniteQueryObserverOptions.md)
20​
21## Type Parameters
22​
23### TQueryFnData
24​
25`TQueryFnData` = `unknown`
26​
27### TPageParam
28​
29`TPageParam` = `unknown`
30​
31## Properties
32​
33| Property | Type | Description |
34| ------ | ------ | ------ |
35| <a id="property-getnextpageparam"></a> `getNextPageParam` | (`lastPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `lastPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the next cursor for infinite queries. The result will also be used to determine the value of `hasNextPage`. |
36| <a id="property-getpreviouspageparam"></a> `getPreviousPageParam?` | (`firstPage`: `TQueryFnData`, `allPages`: `TQueryFnData`[], `firstPageParam`: `TPageParam`, `allPageParams`: `TPageParam`[]) => `TPageParam` \| `null` \| `undefined` | This function can be set to automatically get the previous cursor for infinite queries. The result will also be used to determine the value of `hasPreviousPage`. |
37| <a id="property-initialpageparam"></a> `initialPageParam` | `TPageParam` | The page param to start from when an infinite query has no pages yet. It is passed to `queryFn` as `pageParam` for the first page; every page after that gets the value returned by `getNextPageParam` or `getPreviousPageParam`. It only applies while the query has no pages: once a first page exists, refetching starts from that page's own param instead. |