DevTools
TanStack Query DevTools help you visualize all of the inner workings of TanStack Query and will likely save you hours of debugging.Installation
DevTools are available as a separate package:DevTools are automatically excluded from production bundles through tree-shaking, so you don’t need to worry about bundle size.
Basic Setup
Add the DevTools component to your app:DevTools Options
Customize the DevTools behavior with these props:Available Props
initialIsOpen(boolean) - Start with DevTools open or closed. Default:falsebuttonPosition('top-left' | 'top-right' | 'bottom-left' | 'bottom-right') - Position of the toggle button. Default:'bottom-right'position('top' | 'bottom' | 'left' | 'right') - Position of the DevTools panel. Default:'bottom'client(QueryClient) - Custom QueryClient instance (uses context by default)
DevTools Panel
For more control, useReactQueryDevtoolsPanel to embed DevTools in your own UI:
Using DevTools
Once installed, the DevTools provide powerful debugging capabilities:Query Inspector
View all queries in your application:- Active queries - Currently mounted and subscribed
- Inactive queries - No subscribers but still cached
- Stale queries - Need to be refetched
- Fresh queries - Recently fetched and up-to-date
Query Details
Click any query to see:- Query key and hash
- Query status and fetch status
- Data preview (JSON viewer)
- Last updated timestamp
- Observers count
- Data/error information
Actions
Perform actions directly from DevTools:- Refetch - Manually trigger a refetch
- Invalidate - Mark query as stale
- Reset - Reset query to initial state
- Remove - Remove query from cache
Production Builds
DevTools are automatically tree-shaken in production:Lazy Loading (Optional)
For even smaller development bundles, lazy load DevTools:Lazy loading DevTools is useful for large applications where you want to minimize the development bundle size.
DevTools Features
Query Status Colors
Queries are color-coded by status:- Green - Fresh data
- Yellow - Stale data
- Gray - Inactive query
- Blue - Currently fetching
- Red - Error state
Query Filters
Filter queries by status:- Show all queries
- Show only active queries
- Show only inactive queries
- Show only stale queries
- Show only fresh queries
Mutation Tracking
View all mutations:- Mutation status (idle, pending, error, success)
- Variables passed to mutation
- Mutation result
- Error information
Keyboard Shortcuts
DevTools support keyboard shortcuts for quick access:Esc- Close DevTools panelCtrl/Cmd + /- Focus search box
Best Practices
Keep DevTools open during development
Having DevTools visible helps you understand query behavior and catch caching issues early.
Troubleshooting
DevTools not appearing
Ensure:- DevTools are inside
QueryClientProvider - You’re in development mode
- The package is installed correctly
DevTools showing no queries
- Make sure components using
useQueryare mounted - Check that queries aren’t immediately garbage collected (increase
gcTime)
Performance issues with many queries
- Use query filters to show only relevant queries
- Consider lazy loading DevTools
- Close DevTools when not actively debugging
Framework-Specific DevTools
DevTools are available for other frameworks too:Vue Query
Svelte Query
Solid Query
Next Steps
Essential Concepts
Learn core concepts to make the most of DevTools
TypeScript
Use DevTools with full TypeScript support