React Query Best Practices
Helps with React, querying, best practices as part of building frontend UIs and user experiences workflows.
Install on your platform
We auto-selected Claude Code based on this skill’s supported platforms.
Run in terminal (recommended)
claude mcp add react-query-best-practices npx -- -y @trustedskills/react-query-best-practices
Or manually add to ~/.claude/settings.json
{
"mcpServers": {
"react-query-best-practices": {
"command": "npx",
"args": [
"-y",
"@trustedskills/react-query-best-practices"
]
}
}
}Requires Claude Code (claude CLI). Run claude --version to verify your install.
About This Skill
What it does
This skill provides a comprehensive guide to React Query v4 (TanStack Query) based on TkDodo's blog series. It offers 24 prioritized rules across seven categories, covering topics like query keys, mutations, caching strategies, WebSocket integration, and TypeScript usage. The goal is to help developers build efficient and maintainable frontend UIs using React Query best practices.
When to use it
- When implementing new queries or mutations in a React application.
- When integrating WebSockets with React Query for real-time data updates.
- To establish effective query invalidation patterns after data modifications.
- For debugging unexpected behavior within your React Query implementation.
- When optimizing the render performance of components using React Query.
Key capabilities
- Prioritized Rules: Provides 24 rules categorized by impact (Critical, High, Medium).
- Query Key Management: Guidance on creating consistent and effective query keys (
query-keys-as-dependencies,query-key-factory). - Mutation Handling: Best practices for mutations and updates including invalidation and optimistic updates (
mutation-invalidation,mutation-optimistic-updates). - Caching Strategies: Advice on managing the React Query cache effectively (
cache-). - WebSocket Integration: Patterns for integrating WebSockets with React Query.
- TypeScript Support: Guidance on using React Query with TypeScript.
Example prompts
- "What are some best practices for creating query keys in React Query?"
- "How should I handle mutations and ensure queries are invalidated afterwards?"
- "Can you explain the difference between
placeholderandinitialdata in a React Query query?" - "I'm integrating WebSockets with React Query, what patterns should I follow?"
Tips & gotchas
- React Query Version: This skill is specifically tailored for React Query v4. Patterns may differ in version 5.
- Prioritization: Focus on the "Critical" and "High" priority rules first to maximize impact.
- Rule Prefixes: Rules are categorized using prefixes like
query-,mutation-,cache-for easy identification (e.g.,query-keys-as-dependencies).
Tags
TrustedSkills Verification
Unlike other registries that point to live repositories, TrustedSkills pins every skill to a verified commit hash. This protects you from malicious updates — what you install today is exactly what was reviewed and verified.
Security Audits
| Gen Agent Trust Hub | Pass |
| Socket | Pass |
| Snyk | Pass |
🌐 Community
Passed automated security scans.