tanstack-query

Manage React server-state with TanStack Query v5 data fetching, caching, and mutations.

Updated Feb 6, 2026
One-click install
npx skills add https://github.com/VV01T3K/Better-Constax-Template --skill tanstack-query-vv01t3k
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-query
Source: https://github.com/VV01T3K/Better-Constax-Template/tree/main/.agents/skills/tanstack-query
Command: npx skills add https://github.com/VV01T3K/Better-Constax-Template --skill tanstack-query-vv01t3k

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Centralizes and simplifies server-state management for React apps, providing a robust layer for fetching, caching, and mutating data across components.

Core Features & Use Cases

  • useMutationState for global mutation tracking
  • Simplified optimistic updates and throwOnError
  • Network mode options for offline/PWA
  • infiniteQueryOptions helper for robust infinite queries
  • Migration aids for v4→v5 (object syntax, gcTime, isPending, keepPreviousData)
  • SSR/hydration debugging for streaming server components

Quick Start

Install and configure TanStack Query v5 in your React app to start fetching and mutating server data.

Frequently Asked Questions about tanstack-query

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

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

TanStack Query v5 migration requires adopting object syntax for hooks, replacing cacheTime with gcTime, using isPending for initial loading, and updating infiniteQueryOptions. Migration aids help transition keepPreviousData and other deprecated v4 patterns to the new v5 server-state API.

How do I handle optimistic updates with useMutationState in TanStack Query?

Optimistic updates in TanStack Query v5 use useMutationState for global mutation tracking alongside useMutation. This coordinates server-state mutations by applying temporary cache changes before server confirmation, simplifying rollback logic and mutation state management across React components.

Does TanStack Query v5 support offline network modes for PWA applications?

TanStack Query v5 supports offline and PWA scenarios through network mode options. These configuration settings control how data fetching and cache management behave during connectivity loss, allowing server-state queries to queue or fail gracefully based on the specified network mode.

Why is my TanStack Query SSR hydration not working with streaming server components?

SSR hydration debugging in TanStack Query v5 addresses streaming server component synchronization issues. Server-state data must be properly dehydrated on the server and rehydrated on the client to prevent cache mismatches and ensure correct rendering of fetched data.

What is the best way to configure infinite queries with TanStack Query v5?

TanStack Query v5 provides the infiniteQueryOptions helper for robust infinite query configuration. This approach centralizes pagination parameters and query functions for server-state data fetching, ensuring proper cache management and seamless infinite scrolling behavior.

How does throwOnError change error handling in TanStack Query v5?

throwOnError in TanStack Query v5 propagates query errors to the nearest React error boundary instead of returning them in the state object. This simplifies server-state error handling by leveraging component-level error catching rather than per-query conditional rendering.