hassanzohdy/atomic-query/infinite
Claude Code and agent skill by hassanzohdy/atomic-query
- community
Checking that the SKILL.md file is still in the repository.
How to use useInfiniteQuery for cursor-based and offset-based paginated lists, including fetchNextPage, hasNextPage, and invalidation behavior.
Install
npx vskill@latest install hassanzohdy/atomic-query/infiniteSKILL.md
Infinite / paginated queries
useInfiniteQuery is the cursor-paginated cousin of useQuery. The cached value is { pages, pageParams } — an array of fetched pages and the cursor used for each. Each call to fetchNextPage() computes the next cursor via getNextPageParam and appends the result.
Built on top of queryAtom.useQuery, so cache invalidation, GC, observer counting, and refetch-on-focus all work for free.
Signature
Behavior
- First fetch. Standard
useQuery-style: runsqueryFn({ pageParam: initialPageParam, signal })and wraps the result in{ pages: [page], pageParams: [initialPageParam] }. - `fetchNextPage()` computes the next param via
getNextPageParam, fetches, and appends to bothpagesandpageParams. Each call has its ownAbortControllerso multiple in-flight page fetches can be aborted independently. - `hasNextPage` is
truewhengetNextPageParam(lastPage, ...)returns a non-undefined, non-nullvalue. - `isFetchingNextPage` is local to the hook — separate from the cached query's
isFetching(which reflects whole-query refetches like invalidation). - Invalidation of the query key refetches starting from page 1; the
pagesarray shrinks back to length 1.
Examples
Cursor-based pagination
Offset-based pagination
Stop condition based on total
Invalidation refetches from page 1
If you want a "soft refresh" that keeps prior pages but refetches them, build it yourself:
Gotchas
- `getNextPageParam` returning `undefined` vs `null`. Both stop pagination; pick whichever your API returns naturally.
- `fetchNextPage()` while already fetching. Calling it twice in quick succession spawns a second controller and a second request — the first one isn't aborted. If you want to debounce, wrap the call site.
- `pages` grows unbounded. For very long feeds, consider virtualizing the render and trimming the
pagesarray when the user scrolls back to the top. - Cache invalidation resets the pagination. If you
invalidate({ queryKey: ["posts"] }), you get one fresh page. To preserve scroll position you'll need a custom pattern.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/infinite/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/hassanzohdy/atomic-query/infinite)