Solid Query DevTools
The Solid Query DevTools provide a visual interface to inspect, debug, and manage your queries and mutations during development. They’re an essential tool for understanding what’s happening under the hood.Installation
Install the DevTools package as a dependency:Basic Usage
Add theSolidQueryDevtools component to your application:
The DevTools component should be placed inside the
QueryClientProvider but can be anywhere in your component tree.Features
The DevTools provide comprehensive visibility into your application’s query state:Query Explorer
- View All Queries: See all queries registered with the QueryClient
- Query Status: Visual indicators for loading, success, error, and stale states
- Query Details: Inspect query data, error messages, and metadata
- Cache Time: See when queries were last fetched and when they’ll be garbage collected
Query Actions
- Refetch: Manually trigger a refetch for any query
- Invalidate: Invalidate queries to mark them as stale
- Reset: Reset queries to their initial state
- Remove: Remove queries from the cache
Mutation Tracking
- Active Mutations: Monitor mutations in progress
- Mutation History: Review completed mutations and their results
- Mutation State: See pending, success, and error states
Configuration Options
Customize the DevTools appearance and behavior:Available Options
| Option | Type | Default | Description |
|---|---|---|---|
initialIsOpen | boolean | false | Whether the DevTools are open by default |
position | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'bottom-left' | Position of the DevTools panel |
buttonPosition | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'bottom-left' | Position of the toggle button |
client | QueryClient | Uses context | Specific QueryClient to use |
DevTools Panel
For more control, use theSolidQueryDevtoolsPanel component:
Panel Options
The panel component accepts additional configuration:Production Builds
The DevTools checkisDev from solid-js/web and return null in production:
Development Only Usage
If you want to ensure DevTools are only available in development:Debugging Queries
Inspecting Query State
Use the DevTools to inspect detailed query information:- Data Tab: View the current data in the cache
- Query Tab: See query configuration and options
- Observers Tab: Monitor active observers subscribed to the query
- Actions: Perform manual operations on queries
Monitoring Fetch Behavior
Track when queries refetch:Debugging Cache Behavior
Understand cache timing:- When data becomes stale
- When inactive queries are scheduled for garbage collection
- Active observers keeping queries alive
Mutation Debugging
Track mutation lifecycle:- Active mutations and their status
- Mutation variables and results
- Error messages for failed mutations
Query Cache Exploration
Inspect the entire cache state:Performance Monitoring
Use DevTools to identify performance issues:Over-fetching Detection
Identify queries that refetch too frequently:- Open DevTools
- Watch the “Last Updated” column
- Look for queries updating more often than necessary
- Adjust
staleTimeaccordingly
Memory Leaks
Spot queries that aren’t being garbage collected:- Check the “Observers” count
- Look for inactive queries with high observer counts
- Ensure proper cleanup in components
Unnecessary Renders
Identify components re-rendering due to query updates:Keyboard Shortcuts
When DevTools are open:- Escape: Close DevTools
- Click Logo: Toggle DevTools panel
Best Practices
- Keep DevTools Open: During development, keep DevTools visible to monitor query behavior
- Check Query Keys: Verify query keys are correctly structured and unique
- Monitor Refetch Behavior: Ensure queries aren’t refetching unnecessarily
- Inspect Error States: Use DevTools to debug query and mutation errors
-
Validate Cache Strategy: Confirm
staleTimeandgcTimeare appropriate - Track Mutations: Monitor mutation success/failure rates
Troubleshooting
DevTools Not Showing
If DevTools don’t appear:- Check Import: Ensure you’re importing from
@tanstack/solid-query-devtools - Verify Provider: DevTools must be inside
QueryClientProvider - Development Mode: Confirm you’re running in development mode
- Position: Check if DevTools are off-screen due to positioning
Performance Impact
DevTools are optimized for minimal performance impact, but they do add overhead. They’re automatically excluded from production builds.
Multiple Query Clients
If using multiple QueryClients:Custom DevTools Integration
For advanced use cases, access the underlying DevTools API:Next Steps
Overview
Learn about Solid Query core concepts
TypeScript
Explore TypeScript integration