trpc Pagination
Does somebody have any example how can i do pagination in trpc and react query?
3 Replies
Hi,
I haven't had that usecase but I was mostly refering to Tanstack React Query docs, whatever you do with react query you can do with TRPC wrapper.
I would pass query params to trpc route (page, limit) and do logic in trpc route and keep (page and limit) on client.
This might help
https://tanstack.com/query/v4/docs/react/examples/react/pagination
React Query Pagination Example | TanStack Query Docs
An example showing how to implement Pagination in React Query
danke
i will try it
You can also do a infinite query which is RQ, but we have a special extension of it for type safety: https://trpc.io/docs/client/react/useInfiniteQuery
useInfiniteQuery | tRPC
- Your procedure needs to accept a cursor input of any type (string, number, etc) to expose this hook.