Tanstack Query Best Practices

Production conventions for TanStack Query (React Query): a five-file feature folder (types/requests/keys/queries/mutations), queryOptions() key factories with a single all() root per feature for hierarchical invalidation, QueryConfig/MutationConfig type helpers, optimistic updates with rollback, and useInfiniteQuery patterns. Use when adding, refactoring, or reviewing server-state or data-fetching code — useQuery, useMutation, useInfiniteQuery, queryClient, .queries.ts/.mutations.ts files — even when the user doesn't name the library.

AlshehriAli0 1d5c9be 35 files · 162.7 KB Updated

File contents

AlshehriAli0/agent-skills/tree/main/skills/tanstack-query-best-practices commit 1d5c9bed0c

Frequently asked questions

npx skillmds@latest add alshehriali0/tanstack-query-best-practices