- Home
- Skills
- Cameronapak
- Bknd Skills
- Bknd Pagination
bknd-pagination_skill
2
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill cameronapak/bknd-skills --skill bknd-pagination- SKILL.md16.1 KB
Overview
This skill explains how to implement limit/offset pagination with Bknd for lists, tables, infinite scroll and APIs. It covers page calculation, response metadata (total, hasNext, hasPrev), helper functions, REST query patterns, and React integration examples. Practical snippets and patterns help avoid common pitfalls like off-by-one errors and unpaginated queries.
How this skill works
It inspects and uses Bknd's offset-based pagination parameters: limit and offset. The skill shows how to derive offset from a 1-indexed page, read meta.total from responses, and compute totalPages, hasNext, and hasPrev. It also demonstrates helper functions for consistent pagination results, REST query usage, and client-side patterns for load-more and infinite scroll.
When to use it
- Displaying long lists or table views in a UI
- Implementing page-based navigation (Prev/Next and page numbers)
- Building Load More buttons or infinite scroll feeds
- Creating server-side rendered pages or API endpoints with paginated results
- Searching or filtering results with pagination
Best practices
- Always limit queries to avoid loading all records; set a sensible default page size
- Treat pages as 1-indexed and compute offset as (page - 1) * pageSize
- Return pagination metadata (total, limit, offset) so clients can compute totalPages and navigation
- Use helper functions that return consistent shape: data, page, pageSize, total, totalPages, hasNext, hasPrev
- For React, prefer SWR or similar data fetching to cache and sync pages; use IntersectionObserver for auto-loading
Example use cases
- Server API endpoint that returns paginated posts with meta for total and pages
- React paginated list with Prev/Next and numbered pages using page state and readMany
- Infinite scroll feed using offset = currentItemCount, updating hasMore from meta.total
- Search UI that combines filters with pagination to drill through results
- Next.js server-side page that fetches paginated data and renders PaginationLinks
FAQ
Use offset = (page - 1) * pageSize. For page 3 and pageSize 20 offset = (3 - 1) * 20 = 40.
How can I know there is a next page?
Compare meta.offset + meta.limit < meta.total. If true, there are more records to fetch.