Skip to main content
The Svelte Query DevTools help you visualize all of the inner workings of Svelte Query and will likely save you hours of debugging if you find yourself in a pinch.

Installation

1

Install the package

Install the DevTools package as a dev dependency:
The DevTools package version is 6.0.4 and is compatible with @tanstack/svelte-query 6.0.0+.
2

Import and add to your app

Add the SvelteQueryDevtools component to your root layout:
+layout.svelte
Place the DevTools component anywhere inside the QueryClientProvider. It’s common to put it at the end of your layout.
3

Start your app

The DevTools will now appear in your app during development. They are automatically removed from production builds.

Features

The Svelte Query DevTools provide powerful debugging capabilities:

Query Explorer

View all queries in your application:
  • Active queries - Currently mounted and in use
  • Inactive queries - Cached but not mounted
  • Stale queries - Data that needs refetching
  • Fresh queries - Recently fetched data

Query Inspector

Click on any query to see detailed information:
  • Query key
  • Query status (pending, error, success)
  • Last updated timestamp
  • Data preview
  • Query configuration
  • Observers count
  • Query tags

Mutation Inspector

Track all mutations in your app:
  • Mutation status
  • Variables passed to mutation
  • Mutation response data
  • Error information

Actions

Perform actions on queries:
  • Refetch - Manually trigger a refetch
  • Invalidate - Mark query as stale
  • Remove - Remove query from cache
  • Reset - Reset error state

Configuration

Customize the DevTools appearance and behavior:
+layout.svelte

Options

boolean
default:"false"
Set to true to have the DevTools open by default on page load.
string
default:"bottom-right"
Position of the toggle button. Options: 'top-left', 'top-right', 'bottom-left', 'bottom-right'.
string
default:"bottom"
Position of the DevTools panel. Options: 'top', 'bottom', 'left', 'right'.
QueryClient
default:"useQueryClient()"
Custom QueryClient instance. By default, uses the client from context.
Array<DevtoolsErrorType>
default:"[]"
Custom error types to display in the DevTools.
string
Nonce for Content Security Policy (CSP). Used for inline styles.
ShadowRoot
Attach DevTools styles to a specific Shadow DOM target.
boolean
default:"false"
Hide disabled queries from the query list.

Usage Examples

Basic Setup

The simplest configuration:
+layout.svelte

Custom Position

Position the DevTools on the right side:

Open by Default

Useful during development:

With SvelteKit

Only show DevTools in development:
+layout.svelte
The DevTools are automatically tree-shaken from production builds, but you can add an explicit check for clarity.

DevTools Interface

Query States

Queries are color-coded by state:
  • Green - Fresh data (within staleTime)
  • Yellow - Stale data (needs refetch)
  • Gray - Inactive (cached but not mounted)
  • Blue - Fetching (currently refetching)
  • Red - Error state

Filter Queries

Use the search bar to filter queries:

Sort Queries

Sort queries by:
  • Query key
  • Last updated
  • Observer count
  • Status

Debugging Tips

1

Inspect query keys

Click on a query to see its full query key structure. This helps ensure your keys are unique and properly structured.
2

Monitor refetch behavior

Watch the “Last Updated” timestamp to see when queries refetch. This helps debug issues with:
  • staleTime configuration
  • Window focus refetching
  • Interval refetching
3

Check observer count

The observer count shows how many components are using a query. If it’s 0, the query is inactive and may be garbage collected.
4

Inspect error states

When a query fails, click on it to see:
  • Error message
  • Error stack trace
  • Failed query configuration
  • Retry count

Advanced Features

Custom Error Types

Display custom error information:

Shadow DOM Integration

For apps using Shadow DOM:

CSP Nonce Support

For Content Security Policy compliance:

Performance

The DevTools are designed to have minimal performance impact:
  • Lazy loaded - Only imported when used
  • Development only - Automatically removed in production
  • Efficient updates - Only re-renders when query state changes
  • Virtual scrolling - Handles thousands of queries efficiently
While the DevTools are optimized, having hundreds of active queries may slow down the interface. Consider using query filters or hideDisabledQueries in such cases.

Keyboard Shortcuts

Use keyboard shortcuts for faster navigation:
  • Cmd/Ctrl + K - Toggle DevTools
  • / - Focus search
  • ↑/↓ - Navigate queries
  • Enter - Open selected query
  • Esc - Close query detail

Troubleshooting

DevTools not appearing

Check that:
  1. You’re in development mode
  2. The component is inside QueryClientProvider
  3. The package is installed correctly

DevTools in production

The DevTools should be automatically removed. If they appear in production:
  1. Check your build configuration
  2. Ensure you’re using a production build:

Styling conflicts

If DevTools styles conflict with your app:
  1. Use shadowDOMTarget to isolate styles
  2. Adjust position and buttonPosition
  3. Apply custom CSS overrides

Implementation Details

The DevTools component is implemented in /packages/svelte-query-devtools/src/Devtools.svelte and uses:
  • Svelte 5 runes - $state, $effect, $derived
  • Dynamic import - Lazy loads @tanstack/query-devtools
  • Environment detection - DEV and BROWSER from esm-env
  • QueryClient integration - Uses useQueryClient and onlineManager

Next Steps

1

Explore Advanced Features

Learn about SSR, persistence, and more advanced patterns.Advanced Guides →
2

Production Deployment

Learn best practices for deploying Svelte Query apps.Best Practices →

Resources

The Svelte Query DevTools are maintained as part of the TanStack Query project and follow the same versioning and release cycle.