Skip to main content
The useInfiniteQuery hook is used for fetching paginated or infinite scrolling data. It manages multiple pages of data and provides helpers for loading more pages.

Import

Signature

Parameters

object
required
The infinite query options object.
QueryClient
Override the default QueryClient.

Returns

object
The infinite query result object.

Examples

Cursor-based Pagination

Offset/Limit Pagination

Bi-directional Pagination

With Max Pages

Flattening Pages with Select

Notes

The initialPageParam is required and should match the type of your page parameters.
Return undefined or null from getNextPageParam to indicate there are no more pages.
The data object has a specific shape: { pages: TQueryFnData[], pageParams: TPageParam[] }