tanstack-query

Standardize TanStack Query v5 data fetching with object syntax and caching patterns.

8|Updated Feb 7, 2026
One-click install
npx skills add https://github.com/crafter-station/cs.chat --skill tanstack-query-crafter-station
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-query
Source: https://github.com/crafter-station/cs.chat/tree/main/.agents/skills/tanstack-query
Command: npx skills add https://github.com/crafter-station/cs.chat --skill tanstack-query-crafter-station

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TanStack Query provides a robust, declarative way to manage server state in React applications, handling caching, background updates, and data synchronization across components, including SSR complexities, with migration-friendly practices.

Core Features & Use Cases

  • Object syntax for all hooks (useQuery, useMutation) to ensure consistency and type-safety.
  • Advanced patterns: queryOptions factories, useQueries, infiniteQueryOptions, placeholderData, and prefetching.
  • Strong SSR/hydration support and robust error handling with mutation-driven invalidations.

Quick Start

Install the library, configure a QueryClient, and migrate your hooks to the v5 object syntax to start using TanStack Query.

Frequently Asked Questions about tanstack-query

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

FAQPage Schema
How do I migrate React Query hooks to the v5 object syntax for useQuery and useMutation?

To migrate React Query hooks to v5 object syntax, refactor useQuery and useMutation calls to pass a single arguments object instead of positional parameters, ensuring consistency and type-safety for your server-state data fetching.

What is the best way to manage server-state caching and background refetching in React?

The best way to manage server-state caching and background refetching in React is using TanStack Query, which declaratively handles data synchronization, cache invalidation, and garbage collection time (gcTime) across components.

How do I configure infinite queries with initialPageParam in React?

To configure infinite queries in React, use the infiniteQueryOptions and useInfiniteQuery hooks, specifying initialPageParam to establish the starting point for paginated server-state data fetching.

How do I handle SSR hydration and prefetching for React data fetching?

To handle SSR hydration and prefetching for React data fetching, configure your QueryClient on the server, prefetch queries, then dehydrate and hydrate the state on the client to prevent waterfall requests.

Can I create reusable query configurations using queryOptions factories in React?

Yes, you can create reusable query configurations using queryOptions factories in React to standardize query keys, functions, and structural sharing across multiple components.

How do I implement optimistic updates and mutation-driven invalidations for cross-component state?

To implement optimistic updates and mutation-driven invalidations for cross-component state, use useMutation to update the cache immediately, then trigger query invalidation on success or rollback on error.