tanstack-query

Manage and cache server-side data in TypeScript and JavaScript front-end projects.

Updated Apr 4, 2026
One-click install
npx skills add https://github.com/TaherMustansir1929/zainy-water-v3 --skill tanstack-query-tahermustansir1929
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-query
Source: https://github.com/TaherMustansir1929/zainy-water-v3/tree/main/.agents/skills/tanstack-query
Command: npx skills add https://github.com/TaherMustansir1929/zainy-water-v3 --skill tanstack-query-tahermustansir1929

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TanStack Query removes the complexity of fetching, caching, synchronizing, and updating remote server data in client applications, reducing boilerplate and preventing stale or inconsistent UI state.

Core Features & Use Cases

  • Automatic Caching & Invalidation: Efficiently cache server responses and invalidate or refetch data by key or predicate.
  • Background Refetching & Stale-While-Revalidate: Keep UI data fresh with configurable refetch strategies and intervals.
  • Pagination & Infinite Loading: Built-in support for paginated and cursor/infinite queries with helpers for prefetching pages.
  • Optimistic Updates & Mutations: Perform optimistic UI updates with rollback support and lifecycle callbacks.
  • SSR & Hydration: Prefetch and dehydrate query state on the server for seamless hydration in client render.
  • Use Case: Ideal for React/TS applications that need robust data fetching with caching, optimistic UX, pagination, and server-rendered hydration.

Quick Start

Initialize a QueryClient, wrap your app with QueryClientProvider, and use useQuery or useMutation hooks to fetch and mutate 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 manage server-state data fetching and caching in a React application?

Server-state data fetching and caching is managed by initializing a QueryClient and using hooks to automatically cache responses, invalidate queries, and synchronize remote data to simplify UI state.

Can I implement optimistic updates and mutations with TanStack Query in TypeScript?

Optimistic updates and mutations are supported in TypeScript projects through built-in lifecycle callbacks, allowing you to apply immediate UI changes with rollback support for robust data synchronization.

Does TanStack Query support SSR hydration and prefetching for Svelte or Solid?

SSR hydration and prefetching are supported across Svelte, Solid, Vue, Angular, and React by prefetching and dehydrating query state on the server for seamless client-side rendering.

What is the best way to handle infinite loading and pagination in a Vue front-end?

Infinite loading and pagination in a Vue front-end are handled using built-in cursor and paginated query helpers, allowing you to prefetch pages and manage loading state automatically.

How does stale-while-revalidate background refetching work for client applications?

Stale-while-revalidate background refetching keeps UI data fresh by serving cached responses immediately while triggering configurable background refetch intervals based on query staleness.

Do I need a specific framework to use query invalidation and automatic caching?

Query invalidation and automatic caching require a JavaScript or TypeScript front-end project using React, Vue, Solid, Svelte, or Angular to handle server data synchronization.