React Query DevTools
The React Query DevTools provide a powerful visual interface for debugging and understanding your query cache during development.Installation
Install the DevTools package:The DevTools package only includes development code when
NODE_ENV === 'development' and is tree-shakeable, making it safe to include in production builds.Basic Setup
Add the DevTools component inside yourQueryClientProvider:
Configuration Options
Customize the DevTools appearance and behavior:Available Options
DevTools Panel
For more control over the DevTools UI, use theReactQueryDevtoolsPanel component:
ReactQueryDevtoolsPanel gives you full control over when and where to display the DevTools UI.Features
Query Inspector
The DevTools provide detailed information about each query:1
Query List
View all queries in your cache with their current status:
- Fresh (green)
- Fetching (blue)
- Stale (yellow)
- Inactive (gray)
2
Query Details
Click on a query to see:
- Query key
- Query state (data, error, status)
- Observers count
- Last updated timestamp
- Data update count
3
Actions
Perform actions on queries:
- Refetch query
- Invalidate query
- Reset query
- Remove query from cache
Query States
Queries are color-coded by status:Cache Explorer
Inspect the query cache structure:Mutation Tracking
Monitor active mutations:- Mutation key (if provided)
- Status (idle, pending, success, error)
- Variables passed to mutate
- Data returned from mutation
- Error information (if failed)
Production DevTools
To use DevTools in production (not recommended for public sites):Debugging Tips
Identify Stale Queries
Yellow (stale) queries indicate data that will refetch on the next interaction:Find Memory Leaks
Look for inactive queries that aren’t being garbage collected:Monitor Refetch Behavior
Watch the blue (fetching) indicator to understand when queries refetch:Debug Query Keys
Inspect query keys to ensure proper invalidation:Keyboard Shortcuts
When DevTools are open:Integration with Browser DevTools
React Query DevTools work alongside browser developer tools:Custom Error Types
Define custom error types for better DevTools display:Shadow DOM Support
Render DevTools inside a Shadow DOM:Troubleshooting
DevTools Not Appearing
1
Check Environment
Ensure
NODE_ENV is set to 'development':2
Verify Installation
Confirm the package is installed:
3
Check Provider
Ensure DevTools is inside
QueryClientProvider:Performance Issues
If DevTools slow down your app:Next Steps
TypeScript
Learn about type-safe debugging
Server-Side Rendering
Debug SSR queries and hydration