Untitled Lesson
Skill Matrix
UNLOCK NODES BY LEARNING NEW TAGS.
What is the primary reason cursor-based pagination maintains roughly constant query performance regardless of how deep into a dataset a client is paging, unlike offset pagination?
💻 Code Challenge | +75 XP
Implement cursor-based pagination for GET /orders sorted by createdAt descending, encoding the cursor as an opaque base64 token and returning a nextCursor in the response for the client to pass on the following request.
A high-traffic infinite-scroll activity feed using offset pagination started showing noticeably slower load times as users scrolled deeper, and occasionally duplicated items. Reorder the steps to migrate this to cursor pagination.
Task: Reorder the blocks in logical sequence to solve the problem.
A.D.A. Interface
Adaptive Didactic Assistant

Pascual Vila
Frontend Instructor // Code Syllabus
The Error //
Exposing the cursor's internal structure directly to the client instead of an opaque encoded token
// Wrong: internal structure exposed directly
?cursorCreatedAt=2024-01-15&cursorId=42
// Correct: opaque, encoded token
?cursor=eyJjcmVhdGVkQXQiOiIyMDI0LTAxLTE1IiwiaWQiOjQyfQ==The Solution //
If a client can see and potentially construct or manipulate the cursor's internal fields directly, it couples the client to the server's internal implementation, making it much harder to change the cursor's structure later without breaking existing clients — and it also risks a client crafting an invalid or malicious cursor value.
The Error //
Choosing cursor pagination for a UI that genuinely requires arbitrary page-number jumping
// Cursor pagination cannot support this UI requirement:
// "Page: [1] [2] [3] ... [47] [Next]" — jump to page 23 directly
// For this need, offset pagination is the better-suited choiceThe Solution //
Cursor pagination fundamentally only supports sequential movement (the next or previous page relative to a specific cursor) — it cannot support jumping directly to an arbitrary page number, since there's no concept of page numbers at all. For a UI genuinely requiring this (like an admin table with numbered page links), offset pagination remains the more appropriate choice despite its other tradeoffs.