usePaginatedQuery
usePaginatedQuery<
TDocument,TCollectionSlug>(props):UsePaginatedQueryReturn<TDocument>
Defined in: packages/react/src/hooks/usePaginatedQuery.ts:132
Hook for cursor-based pagination of VexCMS collections with Load More pattern.
Manages:
- Convex cursor-based pagination using
find()API - Accumulates results across multiple Load More calls
- Extracts
totalCountfrom first page response - Mimics Convex
usePaginatedQueryAPI for consistency
Type Parameters
Section titled “Type Parameters”TDocument
Section titled “TDocument”TDocument extends VexDocument = VexDocument
TCollectionSlug
Section titled “TCollectionSlug”TCollectionSlug extends string = string
Collection slug type
Parameters
Section titled “Parameters”UsePaginatedQueryProps<TDocument, TCollectionSlug>
Hook configuration
Returns
Section titled “Returns”UsePaginatedQueryReturn<TDocument>
Pagination state and controls
Example
Section titled “Example”const { results, totalCount, isDone, loadMore, isLoading,} = usePaginatedCollection({ collection: "posts", initialNumItems: 100, includeTotalCount: true,});
// Show total count in header<p> {totalCount !== null && totalCount !== undefined ? ( <>{totalCount.toLocaleString()} documents</> ) : ( <>10,000+ documents</> )}</p>
// Show Load More button{!isDone && ( <Button onClick={() => loadMore(100)} disabled={isLoading}> {isLoading ? "Loading..." : "Load More"} </Button>)}find- Server function for querying documents- PaginationResult - Return type with totalCount