tanstack-query

Manage server state and data fetching across JavaScript frontend frameworks.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/SeanChenR/maestro-agent --skill tanstack-query-seanchenr
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-query
Source: https://github.com/SeanChenR/maestro-agent/tree/main/.agents/skills/tanstack-query
Command: npx skills add https://github.com/SeanChenR/maestro-agent --skill tanstack-query-seanchenr

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TanStack Query simplifies fetching, caching, synchronizing, and updating remote server state in frontend applications so developers can avoid manual cache management and reduce UI data staleness.

Core Features & Use Cases

  • Automatic Caching & Invalidation: Efficiently cache server responses and invalidate by hierarchical keys for precise refetching.
  • Background Refetching & Retry Policies: Keep data fresh with configurable refetch intervals, reconnect/focus behaviors, and retry strategies.
  • Pagination, Infinite Loading & Optimistic Updates: Built-in patterns for paginated lists, cursor-based infinite queries, and optimistic UI updates with rollback support.
  • Use Case: Use it in a React app to prefetch todos in route loaders, show placeholder data during pagination, perform optimistic add/remove operations, and hydrate server-rendered state on the client.

Quick Start

Wrap your app with a QueryClientProvider, create a QueryClient with sensible defaults, and replace direct fetch calls with useQuery or useMutation hooks as appropriate.

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 and cache data fetching in a React app?

To manage server state and data fetching, use a QueryClient and replace direct fetch calls with useQuery hooks to automatically cache responses and handle background refetching.

What is the best way to implement optimistic updates with rollback support?

The best way to implement optimistic updates is using useMutation hooks, which apply UI changes immediately and provide rollback support if the server synchronization fails.

Does TanStack Query work with Vue, Svelte, Solid, and Angular frontends?

Yes, TanStack Query works across React, Vue, Svelte, Solid, and Angular frontends, providing a unified approach for caching and background refetching server state.

How do I hydrate server-rendered state during SSR?

To hydrate server-rendered state during SSR, prefetch queries in your route loaders and use the QueryClient to serialize and dehydrate state for client-side hydration.

How do I handle pagination and infinite scrolling with cached data?

Handle pagination and infinite scrolling using built-in patterns for paginated lists and cursor-based infinite queries, allowing you to show placeholder data while fetching.

When does manual cache management fail and require automatic invalidation?

Manual cache management fails when UI data becomes stale, requiring hierarchical key-based automatic invalidation to precisely refetch and synchronize server state.