
Tanstack Query
- 196 repo stars
- Updated July 25, 2026
- secondsky/claude-skills
Manage server state in React with TanStack Query v5 — data fetching, caching, and mutations.
About
TanStack Query v5 (React Query) handles server-state management in React. Developers use it for data fetching, caching, and mutations, and to resolve v4 migration, stale-data, and invalidation errors.
- TanStack Query v5
- Data fetching + caching
- Mutations
- v4 migration help
Tanstack Query by the numbers
- Data as of Jul 28, 2026 (Skillselion catalog sync)
/plugin marketplace add secondsky/claude-skills/plugin install tanstack-query@claude-skillsAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| repo stars | ★ 196 |
|---|---|
| Last updated | July 25, 2026 |
| Repository | secondsky/claude-skills ↗ |
What it does
Manage server state in React with TanStack Query v5 — data fetching, caching, and mutations.
README.md
TanStack Query (React Query) v5
Status: ✅ Production Ready Last Updated: 2025-12-09 Production Tested: Patterns verified with TypeScript strict mode
Auto-Trigger Keywords
Claude Code automatically discovers this skill when you mention:
Primary Keywords
- TanStack Query
- React Query
- useQuery
- useMutation
- useInfiniteQuery
- useSuspenseQuery
- QueryClient
- QueryClientProvider
Secondary Keywords
- data fetching
- server state
- caching
- staleTime
- gcTime
- query invalidation
- prefetching
- optimistic updates
- mutations
- query keys
- query functions
- error boundaries
- suspense queries
- React Query DevTools
- v5 migration
- v4 to v5
Error-Based Keywords
- "query callbacks removed"
- "cacheTime not found"
- "loading status"
- "initialPageParam required"
- "useQuery is not a function"
- "keepPreviousData removed"
- "onSuccess removed"
- "onError removed"
- "object syntax required"
- "enabled not available with suspense"
- "placeholderData"
- "isPending vs isLoading"
What This Skill Does
Provides comprehensive knowledge for TanStack Query v5 (React Query) server state management in React applications, including setup, queries, mutations, caching strategies, v4→v5 migration, optimistic updates, infinite queries, and error handling.
Core Capabilities
✅ QueryClient configuration and setup ✅ useQuery, useMutation, useInfiniteQuery patterns ✅ Optimistic updates and cache management ✅ v4 to v5 migration (all breaking changes) ✅ TypeScript patterns and type safety ✅ Error handling strategies ✅ Caching and refetching strategies ✅ DevTools setup and debugging ✅ Testing patterns with MSW
Known Issues This Skill Prevents
| Issue | Why It Happens | Source | How Skill Fixes It |
|---|---|---|---|
| #1: Object Syntax Required | v5 removed function overloads | Migration Guide | Always use useQuery({ queryKey, queryFn }) |
| #2: Query Callbacks Removed | onSuccess/onError removed from queries | v5 Breaking Changes | Use useEffect or move to mutations |
| #3: Status Renamed | loading → pending |
v5 Migration | Use isPending for initial load |
| #4: cacheTime → gcTime | Renamed for clarity | v5 Migration | Use gcTime instead |
| #5: useSuspenseQuery + enabled | enabled option not available | GitHub #6206 | Use conditional rendering |
| #6: initialPageParam Required | v5 requires explicit value | v5 Migration | Always provide initialPageParam |
| #7: keepPreviousData Removed | Replaced with placeholderData | v5 Migration | Use placeholderData: keepPreviousData |
| #8: Error Type Default | Changed from unknown to Error | v5 Migration | Specify error type if non-Error |
When to Use This Skill
✅ Use When:
- Setting up TanStack Query in React app
- Implementing data fetching with useQuery
- Creating mutations with useMutation
- Configuring QueryClient settings
- Migrating from React Query v4 to v5
- Implementing optimistic updates
- Setting up infinite scroll with useInfiniteQuery
- Debugging caching or refetching issues
- Resolving v5 breaking changes
- Implementing suspense queries
- Setting up React Query DevTools
- Writing tests for components using TanStack Query
❌ Don't Use When:
- Managing local UI state (use useState)
- Global client state like theme (use Context/Zustand)
- Simple static data (no need for query library)
- Server-side data fetching (Next.js App Router, Remix)
Quick Usage Example
# Install dependencies (choose one)
pnpm add @tanstack/react-query@latest @tanstack/react-query-devtools@latest
# or
npm install @tanstack/react-query@latest @tanstack/react-query-devtools@latest
# or
bun add @tanstack/react-query@latest @tanstack/react-query-devtools@latest
# Set up QueryClient Provider (see SKILL.md for complete setup)
Result: Full TanStack Query v5 setup with best practices
Full instructions: See SKILL.md
Package Versions (Verified 2025-12-09)
| Package | Version | Status |
|---|---|---|
| @tanstack/react-query | 5.90.12 | ✅ Latest stable |
| @tanstack/react-query-devtools | 5.91.1 | ✅ Latest stable |
| @tanstack/eslint-plugin-query | 5.91.2 | ✅ Latest stable |
| react | 18.0.0+ | ✅ Required |
| typescript | 5.2.0+ | ✅ Recommended |
Dependencies
Prerequisites: None (standalone skill)
Integrates With:
- react-hook-form (optional) - Forms integration
- zod (optional) - Runtime validation
- axios (optional) - HTTP client alternative
File Structure
tanstack-query/
├── SKILL.md # Complete documentation
├── README.md # This file
├── scripts/
│ └── example-script.sh # Bootstrap: installs deps + copies templates
├── examples/ # Focused, ready-to-copy snippets (top 10)
│ └── README.md # Index of scenarios + official links
├── templates/ # Copy-ready code
│ ├── package.json # Dependencies
│ ├── query-client-config.ts # QueryClient setup
│ ├── provider-setup.tsx # App wrapper
│ ├── use-query-basic.tsx # Basic query hook
│ ├── use-mutation-basic.tsx # Basic mutation
│ ├── use-mutation-optimistic.tsx # Optimistic updates
│ ├── use-infinite-query.tsx # Infinite scroll
│ ├── custom-hooks-pattern.tsx # Reusable hooks
│ ├── error-boundary.tsx # Error handling
│ └── devtools-setup.tsx # DevTools config
└── references/ # Deep-dive docs
├── v4-to-v5-migration.md # Complete migration guide
├── best-practices.md # Performance & caching
├── common-patterns.md # Reusable patterns
├── official-guides-map.md # When to load each official doc
├── typescript-patterns.md # Type safety
├── testing.md # Testing with MSW
└── top-errors.md # All errors + solutions
Official Documentation
- TanStack Query Docs: https://tanstack.com/query/latest
- React Integration: https://tanstack.com/query/latest/docs/framework/react/overview
- v5 Migration Guide: https://tanstack.com/query/latest/docs/framework/react/guides/migrating-to-v5
- API Reference: https://tanstack.com/query/latest/docs/framework/react/reference/useQuery
- Context7 Library:
/websites/tanstack_query - GitHub Repository: https://github.com/TanStack/query
- Discord Community: https://tlinz.com/discord
Related Skills
- react-hook-form-zod - Forms with validation
- tailwind-v4-shadcn - UI components and styling
- cloudflare-worker-base - Backend API for queries
Contributing
Found an issue or have a suggestion?
- Open an issue: https://github.com/secondsky/claude-skills/issues
- See SKILL.md for detailed documentation
License
MIT License - See main repo LICENSE file
Production Tested: ✅ Patterns verified with TypeScript strict mode Token Savings: ~65% Error Prevention: 100% (all 8 documented issues) Ready to use! See SKILL.md for complete setup.