Skip to content
Back to skills

Tanstack Query

ASecurity

TanStack Query — server state management with queries, mutations, caching, infinite queries, SSR.

  • 47 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added September 12, 2026
businessreact

Works with

  • cli

Security analysis

A100/100

Scanned September 12, 2026

npx -y skills add skeletorflet/opencode-supreme-setup --skill tanstack-query --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Tanstack Query?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Tanstack Query
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/skeletorflet-tanstack-query/badge)](https://www.skillsdirectory.com/skills/skeletorflet-tanstack-query)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…