On this page3 sections
Every app has The List: orders, chats, articles. And every naive list has the same two bugs - duplicated rows and vanishing rows - both caused by offset pagination meeting live data.
Why offset breaks
Page 1 = rows 1-20. A new row is inserted at the top. Page 2 = rows 21-40 - but row 21 is old row 20. Duplicate. Deletions do the reverse: a row silently skips. Users notice; they just call it “the app is buggy”.
Cursor pagination
Page by a stable sort key instead of a position:
GET /orders?after=2024-06-01T10:22:00Z_ord_8812&limit=20The cursor encodes (created_at, id) - the id breaks ties. Inserts and deletes above your cursor no longer shift your window.
SELECT * FROM orders
WHERE (created_at, id) < ($1, $2)
ORDER BY created_at DESC, id DESC
LIMIT 20;The mobile cache layer
- Cache pages locally (Hive CE/SQLite) keyed by cursor - the list renders instantly on reopen.
- Pull-to-refresh fetches from the top and prepends, deduping by id; it never clears the cache first (that is how you get the white flash).
- Invalidate by entity, not by page: an updated order rewrites that row everywhere it appears.
Boring, predictable lists are a feature. Users cannot name “stable pagination”, but they absolutely feel it.