tanstack-query

Manage server-state data with automatic caching and background refetching.

Updated Apr 14, 2026
One-click install
npx skills add https://github.com/iEnergyy/opsflow --skill tanstack-query-ienergyy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-query
Source: https://github.com/iEnergyy/opsflow/tree/main/.agents/skills/tanstack-query
Command: npx skills add https://github.com/iEnergyy/opsflow --skill tanstack-query-ienergyy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Managing server-state data in modern TS/JS apps is challenging due to the need for caching, synchronization, and handling stale data. TanStack Query provides automatic caching, background refetching, and optimistic updates to keep UI in sync with the server.

Core Features & Use Cases

  • Automatic caching and background refetching with stale-while-revalidate strategies.
  • Rich APIs for queries, mutations, and advanced patterns across React, Vue, Solid, Svelte, and Angular.
  • Real-world use cases include dashboards, lists, and other data-heavy interfaces that require reliable, up-to-date data with predictable cache invalidation.

Quick Start

Install the package, configure a QueryClient, wrap your app with QueryClientProvider, and start fetching with useQuery.

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 caching and background refetching in React?

Server-state caching in React is handled by configuring a QueryClient and wrapping your app with QueryClientProvider. This setup enables automatic caching, background refetching, and stale-while-revalidate strategies to keep your UI reliably synchronized with the server.

How do I implement optimistic updates for data mutations in TypeScript apps?

Optimistic updates for data mutations in TypeScript apps are implemented using the useMutation hook. This allows you to predictably update the UI immediately while handling cache invalidation and background synchronization after the server responds.

Does TanStack Query work with Vue, Solid, Svelte, and Angular for data fetching?

TanStack Query works across Vue, Solid, Svelte, and Angular for data fetching. It provides rich APIs for queries and mutations across these frameworks, making it suitable for dashboards and data-heavy interfaces requiring reliable, up-to-date synchronization.

What is the best way to structure query keys for reliable cache management?

Reliable cache management requires thoughtful query keys structured hierarchically. Using consistent query keys with useQuery ensures predictable cache invalidation, allowing background refetching and stale-while-revalidate strategies to function correctly across your application.

Why do I need a QueryClient to fetch data in TypeScript applications?

A QueryClient is required to fetch data in TypeScript applications because it acts as the central store managing server-state. It must be configured and provided via QueryClientProvider to enable hooks like useQuery and useMutation to handle automatic caching and synchronization.