Spec an infinite scroll feed on a cursor API

Vibe codingMedium25 minMeta style

Your task

Your React and TypeScript app has a social feed on a cursor-paginated API, and you use TanStack Query v5. A coding agent will write the useFeed hook and the list component. New posts arrive all the time, and a post can be deleted while someone is scrolling.

Write the spec you would hand the agent.

What you know:

  • GET /api/feed?cursor=<c>&limit=20 returns { items, nextCursor }, and nextCursor is null on the last page
  • posts get re-ranked, so the same post sometimes appears on 2 pages
  • people scroll for a long time, and a session can load hundreds of pages
  • people open a post, then come back with the browser's back button

Then, in a few sentences: what does "add infinite scroll to the feed" get wrong on the client?