Skip to content
Skills Library
Programming · Building & coding

tanstack-react-query-best-practices

/tanstack-react-query-best-practices

TanStack Query conventions for cache-backed React server state. Use when creating or reviewing React queries, mutations, query keys, or cache updates.

Licence
MPL-2.0
Last repository change
05.09.2026

Assessment and security

90/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content25 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
16
Scripts
0
HTML comments
0
URLs in SKILL.md
1
Deprecation

No signals detected. Repository changed on 05.09.2026, without references to retired models or APIs.

Licence

MPL-2.0, otwarta.

What it does and when to use it

TanStack Query conventions for cache-backed React server state. Use when creating or reviewing React queries, mutations, query keys, or cache updates.

Original author description

TanStack Query conventions for cache-backed React server state. Use when creating or reviewing React queries, mutations, query keys, or cache updates.

How it works

  1. Library Sources
  2. References
Original SKILL.md headings · 34 lines, 301 words
SKILL.md preview
---
name: tanstack-react-query-best-practices
description: TanStack Query conventions for cache-backed React server state. Use when creating or reviewing React queries, mutations, query keys, or cache updates.
license: MPL-2.0
metadata:
  author: 'Basti Ortiz <ortiz@bastidood.dev>'
  source: 'https://github.com/BastiDood/skills'
---

# TanStack React Query Best Practices

Treat server data as cache-backed asynchronous state with an explicit owner, identity, and view boundary; the outcome is reliable loading and error handling plus focused updates after writes.

## Library Sources

- GitHub repository ID: `TanStack/query`
- Context7 library ID: `/tanstack/query`
- DeepWiki repository ID: `TanStack/query`

Use Context7 for current documentation and DeepWiki for implementation details.

## References

Read the references that apply to the current task before writing or reviewing TanStack Query code.

1. Let TanStack Query own server-request lifecycle and cache identity.
   - [Let TanStack Query own request lifecycle](./references/request-ownership.md) rather than duplicating it with effects and local state.
   - [Put every response-changing request input in cache identity](./references/cache-identity.md) so distinct results never reuse one entry.
   - [Read request inputs exclusively from the query function's context argument](./references/query-function-inputs.md), never from captured request variables.
   - [Preserve absent identifiers and disable the request](./references/absent-identifiers.md) instead of fabricating a record key.
   - [Partition visibility-sensitive cached data by actor identity](./references/actor-identity-and-secrets.md) without exposing credentials in keys.
2. Resolve query status before presentation consumes data.
   - [Resolve query status at a Loader and Inner boundary](./references/loader-and-inner.md), keeping presentation free of optional data and transport state.
   - [Publish query identity through loader prop contracts](./references/loader-prop-contracts.md) while resolved components receive non-null data.
   - [Destructure only consumed query fields](./references/result-destructuring.md) so dependencies and props express semantic needs.
3. Keep mutation data, callbacks, and cache updates scoped to each operation.
   - [Consume named mutation result fields](./references/mutation-result-destructuring.md) because the complete `useMutation` result is not referentially stable.
   - [Pass changing operation input through mutation variables](./references/mutation-variables.md), not a mutation hook's construction closure.
   - [Parse user-controlled values before mutation invocation](./references/mutation-form-integration.md).
   - [Separate mutation callback lifecycles](./references/mutation-callback-lifecycle.md) by putting every-invocation policy in the definition and mounted UI consequences at the call site instead of aggregate-status effects.
   - [Invalidate the narrow stale entry identified by successful variables](./references/mutation-invalidation.md).
Files in this package (16)
  • LICENSE.txt 16 KB
  • SKILL.md 3 KB
  • agents/openai.yaml 1 KB
  • references/absent-identifiers.md 2 KB
  • references/actor-identity-and-secrets.md 1 KB
  • references/cache-identity.md 2 KB
  • references/loader-and-inner.md 2 KB
  • references/loader-prop-contracts.md 1 KB
  • references/mutation-callback-lifecycle.md 2 KB
  • references/mutation-form-integration.md 1 KB
  • references/mutation-invalidation.md 1 KB
  • references/mutation-result-destructuring.md 1 KB
  • references/mutation-variables.md 1 KB
  • references/query-function-inputs.md 2 KB
  • references/request-ownership.md 2 KB
  • references/result-destructuring.md 1 KB

Versions

RepositoryScoreLicence
This page · Casper-Studios/casper-marketplace90MPL-2.0
bastidood/skills90MPL-2.0

Database snapshot: 13.11.2026 · package version 98a7c2922c92 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 90tanstack-svelte-query-best-practices
    TanStack Query conventions for reactive, cache-backed Svelte server state. Use when creating or reviewing Svelte queries, mutations, query keys, or cache updates.
  • 95tanstack-query-best-practices
    TanStack Query (React Query) best practices for data fetching, caching, mutations, and server state management. Activate when building data-driven React applications with server state.
  • 90TanStack Query
    Expert guidance for TanStack Query (React Query) including queries, mutations, caching, invalidation, optimistic updates, pagination, and infinite queries. Use this when managing server state in React applications.
  • 90tanstack-react-table-best-practices
    TanStack Table v9 conventions for stable React table schemas and instance behavior. Use when creating or reviewing React tables, columns, metadata, or rendering.
  • 91tanstack-query
    TanStack Query v5 (React Query) server state management. Use for data fetching, caching, mutations, or encountering v4 migration, stale data, invalidation errors.
  • 100react-query-best-practices
    React Query v4 (TanStack Query) best practices, patterns, and troubleshooting. Use when working with useQuery, useMutation, query invalidation, caching, WebSocket integration, or any async state management in React. Based on TkDodo's comprehensive blog series.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.