tanstack-query

Manage React server state with TanStack Query v5 patterns.

Updated Jan 17, 2026
One-click install
npx skills add https://github.com/AndyMarigoldLabs/continuous-funding --skill tanstack-query-andymarigoldlabs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-query
Source: https://github.com/AndyMarigoldLabs/continuous-funding/tree/main/.claude/skills/tanstack-query
Command: npx skills add https://github.com/AndyMarigoldLabs/continuous-funding --skill tanstack-query-andymarigoldlabs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill addresses the complexity of implementing and maintaining robust server-state management in React applications using TanStack Query v5, covering data fetching, caching, and synchronization.

Core Features & Use Cases

  • Query key factories: Create structured, hierarchical keys to ensure accurate cache invalidation.
  • Data transformation & select: Transform data in the query function or via select for optimized renders.
  • Mutations & optimistic updates: Implement mutations with cache updates and rollback strategies.
  • Authentication integration: Handle token refresh and protected queries with enabled flags.
  • Testing & MSW: Mock server responses for reliable unit/integration tests.
  • Suspense integration: Use first-class Suspense hooks for cleaner components.

Quick Start

Install TanStack Query v5, wrap your React app with a QueryClientProvider, and create a simple useQuery hook. Then progressively adopt mutations, select-based transforms, prefetching, suspense, and test utilities with MSW as needed.

Frequently Asked Questions about tanstack-query

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

FAQPage Schema
How do I manage server state in React with TanStack Query?

Manage server state in React by installing TanStack Query v5 and wrapping your app with a QueryClientProvider to handle data fetching, caching, and synchronization across client-server interactions.

How do I structure query keys for cache invalidation in react-query?

Structure query keys using hierarchical query key factories to ensure accurate cache invalidation. This pattern organizes dependencies clearly, allowing precise control over which cached server state updates when mutations occur.

Does TanStack Query v5 work with Suspense for data fetching?

TanStack Query v5 works with Suspense by providing first-class Suspense hooks, allowing you to handle data fetching with cleaner React components that suspend until server state is fully loaded.

How do I test react-query data fetching with MSW?

Test react-query data fetching by using Mock Service Worker (MSW) to mock server responses, ensuring reliable unit and integration tests for your query functions and mutation workflows without hitting live APIs.

What is the best way to handle optimistic updates with react-query mutations?

Handle optimistic updates by implementing react-query mutations with structured cache updates and rollback strategies, allowing the UI to reflect expected server state changes immediately before confirmation.

Can I use TanStack Query for authentication and token refresh flows?

TanStack Query handles authentication by using enabled flags to gate protected queries and managing token refresh workflows, ensuring server state requests automatically pause or retry when authorization credentials expire.