tanstack-query

Implement TanStack Query v5 server state management in React applications.

Updated Dec 4, 2025
One-click install
npx skills add https://github.com/dallascrilley/dowser --skill tanstack-query-dallascrilley
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: tanstack-query
Source: https://github.com/dallascrilley/dowser/tree/main/skills/tanstack-query
Command: npx skills add https://github.com/dallascrilley/dowser --skill tanstack-query-dallascrilley

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @tanstack/react-query, @tanstack/react-query-devtools, @tanstack/eslint-plugin-query, and includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve? Setting up TanStack Query v5 correctly is error-prone due to breaking changes from v4, including removed query callbacks, renamed options like gcTime, and required object syntax, leading to migration errors and misconfigured caching. ## Core Features & Use Cases - QueryClient Setup and Configuration: Configure staleTime, gcTime, retry logic, and provider wrapping with DevTools integration. - Queries and Mutations: Implement useQuery, useMutation, useInfiniteQuery with optimistic updates, cache invalidation, and error boundaries. - v4 to v5 Migration: Prevent all 8 documented breaking-change errors such as removed onSuccess callbacks, isPending vs isLoading, and placeholderData replacing keepPreviousData. - Use Case: When migrating a React app from React Query v4 to v5, apply the provided templates and migration references to fix object syntax, status flags, and infinite query parameters without hitting type errors. ## Quick Start Ask the AI to set up TanStack Query v5 in your React project with a configured QueryClient, provider, and a first useQuery hook.

Frequently Asked Questions about tanstack-query

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

FAQPage Schema
How do I set up TanStack Query v5 in a React app?▼

Install @tanstack/react-query, create a QueryClient with staleTime and gcTime defaults, then wrap your app in QueryClientProvider. Add ReactQueryDevtools inside the provider for debugging; it is tree-shaken in production builds.

How to migrate from React Query v4 to v5?▼

Switch all hooks to object syntax like useQuery({ queryKey, queryFn }), replace cacheTime with gcTime, use isPending instead of isLoading, and move query onSuccess callbacks into useEffect. Infinite queries now require an explicit initialPageParam.

Why is isLoading always false in TanStack Query v5?▼

In v5, isLoading means isPending AND isFetching, so it behaves differently than v4. Use isPending to detect the initial loading state when no data exists yet.

Does useSuspenseQuery support the enabled option?▼

No, useSuspenseQuery does not accept the enabled option because suspense guarantees data availability. Use conditional rendering of the component instead to control when the query runs.

How do I implement optimistic updates with useMutation?▼

In onMutate, cancel outgoing queries, snapshot the previous cache with getQueryData, then update it with setQueryData. Roll back in onError using the snapshot and refetch in onSettled via invalidateQueries.

When should I not use TanStack Query?▼

Avoid it for local UI state like modals, which belongs in useState, and for global client state like themes, which fits Context or Zustand better. It is designed for server state, not client-only state.