Skip to main content
Fetch paginated or infinite scrolling data with the createInfiniteQuery function. It manages multiple pages of data and provides methods to load more pages in Svelte 5 applications.

Signature

Parameters

Accessor<CreateInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>>
required
A function (accessor) returning infinite query configuration options.
Accessor<QueryClient>
Accessor returning a custom QueryClient instance. If not provided, uses the client from context.

Returns

object
Reactive infinite query state and methods.

Type Parameters

  • TQueryFnData - Type of data returned by each page
  • TError - Type of error (defaults to DefaultError)
  • TData - Type of final data (defaults to InfiniteData<TQueryFnData>)
  • TQueryKey - Type of the query key (defaults to QueryKey)
  • TPageParam - Type of page parameter (defaults to unknown)

Examples

Basic Infinite Scroll (Svelte 5 Runes)

Cursor-Based Pagination

Bi-directional Pagination

With TypeScript

Reactive Query Parameters

Infinite Scroll with Intersection Observer

Refetch All Pages

With Loading States

Page-Based Pagination

Search with Infinite Scroll

Notes

Svelte Query uses Svelte 5’s runes mode. The options parameter must be an accessor (function) to track reactive dependencies.
initialPageParam is required in v5. Make sure to provide it when creating infinite queries.
When using refetch(), all pages will be refetched. For better UX, consider using invalidateQueries to only refetch when needed.