Skip to content

Cursor Pagination

Medium — good to knowBackend

ELI5 — The Vibe Check

Cursor pagination uses a 'you are here' bookmark instead of page numbers. After getting results, you get a cursor (pointer) to the last item. To get the next batch, you say 'give me everything after THIS item.' It's more reliable than page numbers because it doesn't break when data changes.

Real Talk

Cursor-based pagination uses a pointer (cursor) to mark the position in the dataset, returning items before or after that cursor. It's more stable than offset pagination for real-time data because inserts/deletes don't cause items to shift pages. Used by Twitter, Instagram, and most modern APIs.

Show Me The Code

// First request
GET /api/posts?limit=20
// Response includes: { data: [...], nextCursor: 'post_abc123' }

// Next page
GET /api/posts?limit=20&cursor=post_abc123

When You'll Hear This

"Use cursor pagination for the infinite scroll feed." / "Cursor pagination handles live data better than offset."

Made with passive-aggressive love by manoga.digital. Powered by Claude.