CodePark/ questions / Client–server contract
START PRACTICINGPRACTICE
Frontend question · Frontend system design › Client–server contract

An infinite news feed gets new posts inserted at the top constantly. Which pagination approach fits best?

Cursor pagination with an opaque nextCursor returned by the server

Cursor pagination with an opaque nextCursor fits best. Opaque means the client does not read it. It only sends it back. A cursor points at a specific item, so new posts at the top do not change what the next page returns. "Offset pagination with ?page=3&limit=20" is the tempting wrong answer. With offsets, every new post pushes the other items down. The user then sees duplicates or misses items.