Implement efficient pagination strategies for large datasets using offset/limit, cursor-based, and keyset pagination. Use when returning collections, managing large result sets, or optimizing query performance.
Implement scalable pagination strategies for handling large datasets with efficient querying, navigation, and performance optimization.
Minimal working example:
// Node.js offset/limit implementation
app.get('/api/users', async (req, res) => {
const page = parseInt(req.query.page) || 1;
const limit = Math.min(parseInt(req.query.limit) || 20, 100); // Max 100
const offset = (page - 1) * limit;
try {
const [users, total] = await Promise.all([
User.find()
.skip(offset)
.limit(limit)
.select('id email firstName lastName createdAt'),
User.countDocuments()
]);
const totalPages = Math.ceil(total / limit);
res.json({
data: users,
pagination: {
page,
limit,
total,
totalPages,
hasNext: page < totalPages,
// ... (see reference guides for full implementation)
Detailed implementations in the references/ directory:
| Guide | Contents | |---|---| | Offset/Limit Pagination | Offset/Limit Pagination | | Cursor-Based Pagination | Cursor-Based Pagination | | Keyset Pagination | Keyset Pagination | | Search Pagination | Search Pagination | | Pagination Response Formats | Pagination Response Formats | | Python Pagination (SQLAlchemy) | Python Pagination (SQLAlchemy) |
Copy a source-pinned command for your client. You run it yourself.
Destination: .claude/skills/api-pagination · pinned to the source commit
git clone https://github.com/aj-geddes/useful-ai-prompts.git
cd useful-ai-prompts
git checkout 3f5182cfd739fc113f4af5244a1cf342ad7f7911
mkdir -p ".claude/skills/api-pagination"
cp -r "skills/api-pagination" ".claude/skills/api-pagination"Review the source before running. This copies files into your project; it is not a one-click install and does not verify runtime safety.
Scanner static-checks@0.1.0 · commit 3f5182cfd739. Static checks cannot prove runtime safety – review the source and the exact diff before installing. How checks work.
No static rules matched. This is not a safety guarantee.