tanstack-query

Consolidate TanStack Query v5 guidance for React data fetching and migration.

Updated Feb 4, 2026
One-click install
npx skills add https://github.com/hakushun/ai-dev-starter --skill tanstack-query-hakushun
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-query
Source: https://github.com/hakushun/ai-dev-starter/tree/main/.cursor/skills/tanstack-query
Command: npx skills add https://github.com/hakushun/ai-dev-starter --skill tanstack-query-hakushun

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes assets (resource) and references (resource) components.

What problem does it solve?

TanStack Query v5 can be challenging to adopt and migrate across large React applications. This skill consolidates migration guidance, best practices, and practical patterns for server-state management, data fetching, caching, and SSR hydration.

Core Features & Use Cases

  • Guidance on object-syntax hooks (useQuery, useMutation), advanced features like useMutationState, infiniteQueryOptions, and networkMode.
  • Practical migration notes from v4 to v5, addressing gcTime, isPending, placeholderData, and SSR hydration pitfalls.
  • Examples and references for prefetching, query invalidation, and error handling patterns in real projects.

Quick Start

Install the latest TanStack Query libraries, create a QueryClient and wrap your app with QueryClientProvider, and start using the v5 hooks with object syntax in your components. Review the references for common patterns and migration tips.

Frequently Asked Questions about tanstack-query

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

FAQPage Schema
How do I migrate React Query v4 to TanStack Query v5?

To migrate React Query to TanStack Query v5, transition to object-syntax hooks and update properties like gcTime and isPending. Reviewing migration notes helps address SSR hydration pitfalls and placeholderData changes during the process.

What is the correct syntax for useQuery in TanStack Query v5?

The correct syntax for useQuery in TanStack Query v5 requires object syntax. You must pass an object containing the query key and query function directly to the hook instead of using positional arguments.

How does SSR hydration work with TanStack Query in React?

SSR hydration with TanStack Query involves prefetching data on the server and dehydrating the query state before sending it to the client. The client then hydrates the QueryClient to prevent refetching and ensure server-state consistency.

Can I use infiniteQueryOptions for data fetching in React?

Yes, you can use infiniteQueryOptions for data fetching in React. It is an advanced feature in TanStack Query v5 that allows you to define infinite query configurations separately before passing them to useInfiniteQuery.

What are common TanStack Query migration pitfalls for server-state?

Common TanStack Query migration pitfalls for server-state include mishandling SSR hydration and failing to update deprecated properties. Properly configuring gcTime and understanding placeholderData behavior prevents data fetching inconsistencies.

Does TanStack Query v5 support useMutationState and networkMode?

Yes, TanStack Query v5 supports useMutationState and networkMode. These advanced features enable tracking mutation states across components and customizing fetch behavior during network interruptions or offline scenarios.