Pagination: Offset, Cursor, Infinite Scroll

Compare pagination models for consistency, performance, and UX continuity.

Pattern level: meso

TL;DR

Use cursor pagination for mutable ordered datasets; offset is acceptable for mostly static collections and simple admin tooling.

Problem this solves

  • Determines how incremental loading behaves under concurrent inserts/deletes.
  • Impacts cache design, duplicate handling, and user scroll continuity.

Decision criteria

  • Offset: simple implementation, weak consistency under concurrent writes.
  • Cursor: stronger ordering guarantees, more complex token handling.
  • Infinite scroll: UX mode that can use either offset or cursor transport.

Layered depth

Intro

Pagination is both a data contract and a UX contract; mismatch leads to jumps and duplicates.

Decision criteria

Prefer cursor when list mutation frequency is medium/high or resume continuity matters.

Implementation detail

  • Encode sort key and tie-breaker in cursor token.
  • Keep seen-ID set to drop duplicate records across page boundaries.
  • Preserve anchor index when prepending/appending data.

Failure modes

  • Offset pages shift under inserts and duplicate visible items.
  • Cursor token becomes invalid after backend index changes.
  • Infinite scroll lacks end-state messaging and traps keyboard users.

Pitfalls

  • Mixing sort orders between backend query and client merge logic.
  • Treating cursor token as opaque in logs and losing observability.

Testing and accessibility

Testing + Accessibility Rubric

CategoryLevelRequirementDone When
functionalunitState transitions handle loading, success, empty, and error.Reducer/state machine tests cover all transitions.
functionalintegrationClient correctly maps API contracts into UI-ready view models.Contract fixtures pass with no runtime shape mismatch.
a11yintegrationFull keyboard flow works for primary interaction loop.Tab/Shift+Tab/Enter/Escape scenarios pass for critical controls.
a11ye2eDynamic updates expose meaningful live region announcements.Manual SR checks validate announcement timing and text quality.

Production trade-offs

  • Cursor correctness improves consistency but increases backend coordination cost.
  • Infinite scroll lowers click friction but raises navigation and observability complexity.

Used In Case Studies

Related Patterns