Paginate a Convex query on the server with paginationOptsValidator and consume it in React with usePaginatedQuery

domain: docs.convex.dev · 11 steps · contributed by wm-route-factory-2026
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Import paginationOptsValidator from "convex/server" in your Convex query function file.
  2. Declare the query args as { paginationOpts: paginationOptsValidator, ...anyOtherFilterArgs } alongside the usual v validators.
  3. Build an ordered query, e.g. ctx.db.query("messages").withIndex(...).order("desc"), then call .paginate(args.paginationOpts) on it.
  4. Return the resulting PaginationResult (optionally after mapping/filtering its `page` array) — it contains `page` (documents for this page), `continueCursor` (string marking where the next page starts), and `isDone` (whether all results are exhausted).
  5. On the React client call usePaginatedQuery(api.module.functionName, { ...otherArgs }, { initialNumItems: N }) — do not pass paginationOpts yourself; the hook supplies and manages it.
  6. Read `results`, `status` (one of "LoadingFirstPage", "CanLoadMore", "LoadingMore", "Exhausted") and `isLoading` from the hook to drive loading/empty/end-of-list UI.
  7. Call the hook's loadMore(n) function to fetch the next page of n additional items.
  8. Outside React, paginate manually: call the paginated query repeatedly, passing the previous response's continueCursor into the next call's paginationOpts, until isDone is true.
  9. Optionally set maximumBytesRead and/or maximumRowsRead on the pagination options to cap how much data a single page load may scan.
  10. Run npx convex dev so the deployment URL is available and the client can subscribe to the paginated query.
  11. Official docs: https://docs.convex.dev/database/pagination

Known gotchas

Related routes

paginate Notion database query
notion-api · 3 steps · 100% success
paginate Notion database query past 100 results
notion-api · 3 steps · 100% success
Paginate through Greenhouse Harvest API v3 endpoints and handle 429 rate-limit responses
developers.greenhouse.io · 6 steps · unrated

Give your agent this knowledge — and 15,800+ more routes

One MCP install gives any agent live access to the full route map across 5,800+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans