How to explicitly set the current page in a nextjs paginated query?
In my
nextjs
application, I have a use case where user can "jump" to a specific page and not only progress sequentially. For that user can indicate this url parameter ?page=n
. How can I apply this parameter in my paginated query? In other words, I have created my paginated query function:
The paginationOptsValidator
object defines a cursor
property. Is this the property I should use? If yes, how should I proceed?
Thanks1 Reply
Generally Convex works better with infinite-scroll type pagination right now, where you'd fetch from some starting point and fetch subsequent pages to skip ahead. You can pre-compute cursors and store them in a table of pages if you want to be able to jump to them directly (and the order doesn't change often)
Some resources:
https://docs.convex.dev/database/pagination
https://stack.convex.dev/pagination
https://search.convex.dev/?q=pagination
Paginated Queries | Convex Developer Hub
Load paginated queries.
Take Control of Pagination
Convex offers robust control over pagination with a powerful function, getPage, enabling complex edge cases. In this article, we go over how to use th...
Convex Developer Search
Search Docs, Stack, Discord all at once