writing-react-query

Enforce React Query best practices for data fetching, caching, and mutations.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/anthony-fdez/claude-skills --skill writing-react-query
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: writing-react-query
Source: https://github.com/anthony-fdez/claude-skills/tree/main/.claude/skills/writing-react-query
Command: npx skills add https://github.com/anthony-fdez/claude-skills --skill writing-react-query

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill streamlines data fetching, caching, and server state management in React applications, preventing common pitfalls and ensuring optimal performance.

Core Features & Use Cases

  • Optimized Data Fetching: Implements best practices for useQuery and useMutation.
  • State Management: Guides on separating server state (React Query) from client state (Zustand).
  • Use Case: When building a dashboard that displays real-time user data and product lists, this Skill ensures data is fetched efficiently, cached appropriately, and mutations update the UI seamlessly without redundant state management.

Quick Start

Create a dedicated query hook for fetching user data using useQuery with appropriate staleTime and gcTime configurations.

Frequently Asked Questions about writing-react-query

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

FAQPage Schema
How do I manage server state with React Query instead of global state?

React Query manages server state by handling data fetching and caching, keeping it distinct from global client state. This separation prevents redundant state management and ensures your UI updates seamlessly when server data changes.

What is the best way to configure React Query cache for stale data?

The best way to configure React Query cache is by setting appropriate `staleTime` and `gcTime` values within your `useQuery` hooks. This controls how long fetched data remains fresh and when it gets garbage collected.

Why should I use mutate instead of mutateAsync in React Query?

You should use `.mutate()` with callbacks instead of `.mutateAsync()` to handle mutations safely. This approach prevents unhandled promise rejections and promotes the creation of thin, dedicated mutation hooks for better error handling.

How do I invalidate queries in React Query after a mutation?

Invalidate queries in React Query by triggering query invalidation within your `.mutate()` callbacks. This ensures the cache is marked as stale and automatically refetches active queries to reflect the updated server state.

Does React Query work with Zustand for state management?

Yes, React Query works with Zustand by separating server state from client state. You use React Query for API integration and data fetching, while using Zustand specifically for managing global client state.