Skip to content

About

Opaque cursor pagination helpers for Node.js (base64url JSON cursors).

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

@sandsoftwaresolutions/cursor-pagination

Encode opaque cursors and paginate already-sorted API results without offset drift.

npm install @sandsoftwaresolutions/cursor-pagination

Works with import and require(), and ships TypeScript types for both.

import { paginate } from "@sandsoftwaresolutions/cursor-pagination";

const page = paginate(users, { limit: 20, after: requestUrl.searchParams.get("after") ?? undefined });
return Response.json(page);

The result is { data, pageInfo: { hasMore, nextCursor } }. Pass nextCursor as after for the next page. By default the cursor stores item.id; provide getCursor for a stable compound key such as { createdAt, id }.

encodeCursor and decodeCursor use base64url JSON for transport, not encryption or signing. Do not put secrets in a cursor; use signed links or a server-side session when cursors must be tamper-proof.

About

Opaque cursor pagination helpers for Node.js (base64url JSON cursors).

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages