TanStack Query — server state management with queries, mutations, caching, infinite queries, SSR.
Scanned 9/12/2026
Install to Claude Code
npx -y skills add skeletorflet/opencode-supreme-setup --skill tanstack-query --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Tanstack Query?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/skeletorflet-tanstack-query)More formats (shields.io, HTML) on the badges page.
---
name: tanstack-query
description: TanStack Query — server state management with queries, mutations, caching, infinite queries, SSR.
---
## tanstack-query
### Queries
- `useQuery({ queryKey: ['todos'], queryFn: fetchTodos })` — fetch + cache + auto-refetch.
- Query keys: unique key arrays for cache identity and invalidation.
- `enabled: false` — conditional/disable; `staleTime` — freshness window; `gcTime` — garbage collection.
- `placeholderData: keepPreviousData` — smooth pagination transitions.
### Mutations
- `useMutation({ mutationFn: addTodo, onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }) })`.
- Optimistic updates: `onMutate` — set cache before server; `onError` — rollback; `onSettled` — refetch.
- `mutate(data)` vs `mutateAsync(data)` — fire-and-forget vs promise.
### QueryClient
- `new QueryClient({ defaultOptions: { queries: { staleTime: 5 * 60 * 1000 } } })` — global config.
- `queryClient.invalidateQueries({ queryKey: ['todos'] })` — refetch stale queries.
- `queryClient.setQueryData(['todos'], newData)` — direct cache writes.
- `queryClient.prefetchQuery({ queryKey, queryFn })` — warm cache before render.
### Infinite Queries
- `useInfiniteQuery({ queryKey, queryFn: ({ pageParam }) => fetchPage(pageParam), initialPageParam: 0, getNextPageParam: (last) => last.next })`.
- `fetchNextPage`, `hasNextPage`, `isFetchingNextPage` — pagination UI.
- `useInfiniteQuery` works with `IntersectionObserver` for scroll loading.
### SSR & Devtools
- Hydration: `dehydrate(queryClient)` / `HydrationBoundary` — serialize cache to HTML.
- `<QueryClientProvider>` — required wrapper around app.
- `{ ReactQueryDevtools }` — dev panel for cache inspection.
Is this your skill, or is something wrong with this listing? . Author removals are honored within 72 hours.
No comments yet. Be the first to comment!