tanstack-query-best-practices

Document TanStack Query data-fetching, caching, and mutation practices for React apps.

1|Updated Jan 12, 2026
One-click install
npx skills add https://github.com/JosephAnson/claude-plugin --skill tanstack-query-best-practices-josephanson
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-query-best-practices
Source: https://github.com/JosephAnson/claude-plugin/tree/main/skills/tanstack-query-best-practices
Command: npx skills add https://github.com/JosephAnson/claude-plugin --skill tanstack-query-best-practices-josephanson

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TanStack Query best-practices unify data fetching, caching, mutations, and SSR handling to prevent stale data and cache inconsistencies across React applications.

Core Features & Use Cases

  • Patterns for deterministic data fetching, caching configuration, and error handling.
  • Clear guidance for query keys, invalidation, and mutation flows across common scenarios like lists, pagination, and infinite queries.
  • SSR hydration, suspense integration, and performance optimizations with built-in guardrails.

Quick Start

Install, configure, and apply the rules to structure your query logic across components to ensure robust, scalable server-state management.

Frequently Asked Questions about tanstack-query-best-practices

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

FAQPage Schema
How do I structure TanStack Query keys to prevent stale data and cache inconsistencies in React?

TanStack Query handles server-state management by providing deterministic data fetching, caching configuration, and structured invalidation flows to keep React components synchronized with server data reliably.

How do I configure TanStack Query mutations and invalidation for paginated and infinite queries?

Apply standardized TanStack Query patterns for infinite queries and pagination by defining structured query keys and invalidation rules that maintain cache consistency across mutation flows and list updates.

Does TanStack Query work with React SSR hydration and suspense for server-state management?

Yes, TanStack Query integrates with React SSR hydration and suspense to manage server-state during server-side rendering, utilizing built-in guardrails and performance optimizations for reliable data fetching.

What is the best way to standardize data fetching and error handling across React applications?

Standardize React data fetching and error handling by applying rules-based TanStack Query practices with structured query logic, frontmatter-driven metadata, and robust caching configuration to ensure reliable server-state management.

When should I not use TanStack Query caching for data fetching in my React app?

You should avoid TanStack Query caching when deterministic data requirements fall outside standard server-state management, as misapplied invalidation rules and query keys can introduce stale data and cache inconsistencies.