tanstack-query

Fetch and manage server-state data with TanStack Query v5 hooks.

101|14|Updated Nov 2, 2025
One-click install
npx skills add https://github.com/blencorp/claude-code-kit --skill tanstack-query
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-query
Source: https://github.com/blencorp/claude-code-kit/tree/main/cli/kits/tanstack-query/skills/tanstack-query
Command: npx skills add https://github.com/blencorp/claude-code-kit --skill tanstack-query

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides modern data fetching and state management patterns using TanStack Query v5. It simplifies complex server state synchronization, caching, and mutations, reducing boilerplate and improving the user experience in React applications.

Core Features & Use Cases

  • Suspense-based Queries: Leverage useSuspenseQuery for cleaner components and integrated loading states with React Suspense.
  • Mutations & Optimistic Updates: Manage data modifications with useMutation, including optimistic updates for a snappier UI.
  • Cache Management: Implement intelligent cache invalidation, manual updates, and prefetching strategies to keep your data fresh and performant.
  • Use Case: When building a new feature that displays a list of items and allows users to add new ones, this skill guides you in using useSuspenseQuery for fetching and useMutation with optimistic updates for adding, ensuring a smooth user experience.

Quick Start

Use the tanstack-query skill to create a new useSuspenseQuery hook for fetching a list of posts.

Frequently Asked Questions about tanstack-query

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fetch data in React with caching and automatic synchronization?

Data fetching with TanStack Query handles server state management, caching, and automatic invalidation in React applications. Use useSuspenseQuery or useQuery hooks to fetch data with built-in cache management, eliminating manual synchronization logic and reducing boilerplate.

What's the best way to handle mutations and optimistic updates in React?

Mutations in TanStack Query use useMutation to manage data modifications with optimistic updates that immediately reflect changes in the UI before server confirmation. This approach provides faster perceived performance and seamless user experience during create, update, and delete operations.

How do I integrate Suspense with data fetching in React 18?

useSuspenseQuery integrates React Suspense boundaries with data fetching, automatically handling loading states within your component tree. This eliminates conditional loading UI and produces cleaner, more declarative components in React 18+ applications.

Can I use TanStack Query v5 with my existing React Query code?

TanStack Query v5 requires React 18+ and API updates: isLoading becomes isPending, cacheTime becomes gcTime, and onError/onSuccess/onSettled callbacks are removed. Migration replaces these APIs while preserving core functionality like cache management and prefetching.

What cache invalidation strategies work best for keeping data fresh?

Cache invalidation in TanStack Query uses manual updates, prefetching, and automatic garbage collection (gcTime) to maintain data freshness. Strategies include invalidating on mutation success, prefetching before user navigation, and configuring cache retention policies per query.

Do I need additional setup to integrate TanStack Query with API services?

TanStack Query works with any HTTP client or API service pattern in React. No additional setup beyond installing TanStack Query v5 and wrapping your app with QueryClientProvider is required; hooks directly call your existing API functions.