tanstack-query-expert

Automate asynchronous data handling in React apps with TanStack Query.

Updated Mar 28, 2026
One-click install
npx skills add https://github.com/baselakkad585-maker/basel-dev-skills --skill tanstack-query-expert
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-query-expert
Source: https://github.com/baselakkad585-maker/basel-dev-skills/tree/main/skills/tanstack-query-expert
Command: npx skills add https://github.com/baselakkad585-maker/basel-dev-skills --skill tanstack-query-expert

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TanStack Query Expert reduces boilerplate and flaky data fetching in React apps by replacing ad-hoc useEffect-based requests with a cohesive, cache-driven approach.

Core Features & Use Cases

  • Declarative data fetching using useQuery and custom hooks to encapsulate logic
  • Fine-grained cache control via staleTime, cacheTime, and retry settings, plus automatic cache invalidation on mutations
  • SSR hydration and Next.js App Router integration for seamless server-to-client data sharing

Quick Start

Create a simple useUser hook that fetches data with useQuery, using a stable key and a 5-minute stale time.

Frequently Asked Questions about tanstack-query-expert

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

FAQPage Schema
How do I manage React data fetching and caching without useEffect boilerplate?

React data fetching and caching can be managed declaratively using TanStack Query's useQuery hook, replacing ad-hoc useEffect requests with a cohesive, cache-driven approach that handles staleTime and automatic background updates.

How does cache invalidation work with mutations in React Query?

Cache invalidation with mutations in React Query automatically synchronizes your client state by invalidating specific query keys after a mutation completes, ensuring fetched data reflects server-side changes without manual refetch logic.

What is the best way to handle SSR hydration with TanStack Query in Next.js?

SSR hydration with TanStack Query in Next.js App Router integrates seamlessly, enabling server-to-client data sharing by dehydrating server query states and rehydrating them on the client to maintain consistent cache data.

Can I use optimistic updates with TanStack Query mutations?

Optimistic updates are fully supported with TanStack Query mutations, allowing you to immediately update the UI with expected changes before the server responds, then rolling back automatically if the mutation fails.

How do I configure staleTime and retry behavior for React Query caches?

Configuring staleTime and retry behavior for React Query caches is done within the useQuery options, allowing fine-grained control over how long data remains fresh and how many times failed requests should automatically retry.

Why do I need strict query key design in TanStack Query?

Strict query key design in TanStack Query is required to accurately identify cached data, ensuring correct cache invalidation and preventing stale data conflicts across different query parameters and mutation workflows.