tanstack-query

Centralize server-state management across React, Vue, Svelte, Solid, and Angular.

1|Updated Apr 30, 2026
One-click install
npx skills add https://github.com/Prathamesh-chougale-17/gatekeeper --skill tanstack-query-prathamesh-chougale-17
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-query
Source: https://github.com/Prathamesh-chougale-17/gatekeeper/tree/main/.agents/skills/tanstack-query
Command: npx skills add https://github.com/Prathamesh-chougale-17/gatekeeper --skill tanstack-query-prathamesh-chougale-17

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TanStack Query provides a robust solution to managing server-state in client applications, unifying fetching, caching, invalidation, and synchronization to reduce boilerplate and improve UX.

Core Features & Use Cases

  • Automatic caching, background refetching, and stale-while-revalidate to keep data fresh with minimal manual work.
  • Support for pagination, infinite queries, optimistic updates, and fine-grained invalidation for scalable apps.
  • Works across frameworks (React, Vue, Solid, Svelte, Angular) with a consistent API and tooling.

Quick Start

Install @tanstack/react-query, create a QueryClient, wrap your app with QueryClientProvider, and start using useQuery with a queryKey and queryFn to fetch 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 and cache fetched data in React applications?

To manage server-state in React, you can centralize fetching, caching, and synchronization to reduce boilerplate. Using a queryClient with configurable stale times and background refetching keeps your application data predictable and fresh with minimal manual work.

Can I use TanStack Query for data-fetching in Vue, Svelte, Solid, or Angular?

Server-state management works across Vue, Svelte, Solid, and Angular projects using a consistent API. You apply the same queryFn patterns, query keys, and caching logic to fetch and synchronize data regardless of the framework you choose.

What is the best way to implement optimistic updates and pagination for server data?

The best way to implement optimistic updates and pagination is by using built-in features for infinite queries and fine-grained invalidation. This approach automatically updates the UI before the server response arrives and invalidates query keys to refetch modified data.

How do I set up data-fetching with a queryFn and queryKey in a React app?

To set up data-fetching, install the library, create a QueryClient, and wrap your application with the QueryClientProvider. You then call useQuery by passing a queryKey to identify the data and a queryFn to fetch it.

Why does stale-while-revalidate help with caching server-state in frontend applications?

Stale-while-revalidate caching improves user experience by immediately displaying cached data while fetching fresh data in the background. This mechanism keeps your server-state synchronized and up-to-date without forcing users to wait for network requests to complete.

Do I need to manually configure retries and stale times when fetching server data?

You do not need to manually handle retries and stale times because the system provides configurable options for both. Setting these parameters allows you to control background refetching behavior and automatically retry failed requests for robust data flows.