Skip to main content

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 your QueryClientProvider:
The DevTools will appear as a floating button in the bottom-right corner of your screen (by default).
The DevTools component automatically returns null in production (NODE_ENV !== 'development'), so you don’t need to conditionally render it.

Configuration Options

Customize the DevTools appearance and behavior:

Available Options

DevTools Panel

For more control over the DevTools UI, use the ReactQueryDevtoolsPanel 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:
In DevTools, you’ll see:

Mutation Tracking

Monitor active mutations:
Mutations appear in the DevTools with:
  • 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):
For better control, use lazy loading:
Be cautious when enabling DevTools in production as it exposes your query cache data. Only use this for debugging specific production issues.

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:
Use the DevTools to copy query keys and test invalidation patterns in your code.

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