Developer tools to interact with and visualize the TanStack/svelte-query cache
npx @tessl/cli install tessl/npm-tanstack--svelte-query-devtools@5.86.0Svelte Query Devtools provides developer tools specifically designed for Svelte applications using TanStack Query (formerly React Query). It offers a Svelte component that renders an interactive devtools panel for visualizing and debugging the query cache, inspecting query states, mutations, and cache data.
npm install @tanstack/svelte-query-devtoolsimport { SvelteQueryDevtools } from "@tanstack/svelte-query-devtools";For direct Svelte component imports:
<script>
import { SvelteQueryDevtools } from "@tanstack/svelte-query-devtools";
</script><script>
import { SvelteQueryDevtools } from "@tanstack/svelte-query-devtools";
</script>
<!-- Basic devtools with default settings -->
<SvelteQueryDevtools />
<!-- Devtools with custom positioning -->
<SvelteQueryDevtools
position="top"
buttonPosition="top-left"
initialIsOpen={true}
/>The devtools component is built around several key design patterns:
@tanstack/query-devtools libraryInteractive developer tools component that provides visualization and debugging capabilities for TanStack Query cache in Svelte applications.
/**
* Svelte component that renders TanStack Query devtools interface
* Only renders in development mode and browser environment
*/
interface SvelteQueryDevtoolsProps {
/** Whether the devtools panel should be open by default */
initialIsOpen?: boolean;
/** Position of the devtools toggle button */
buttonPosition?: DevtoolsButtonPosition;
/** Position of the devtools panel */
position?: DevtoolsPosition;
/** TanStack Query client instance to debug (defaults to context client) */
client?: QueryClient;
/** Array of error types to filter in the devtools interface */
errorTypes?: Array<DevtoolsErrorType>;
/** CSP nonce for inline styles (for strict CSP environments) */
styleNonce?: string;
/** Shadow DOM root to render devtools into (for isolated styling) */
shadowDOMTarget?: ShadowRoot;
/** Whether to hide disabled queries from the devtools interface */
hideDisabledQueries?: boolean;
}Component Props:
Usage Examples:
<script>
import { SvelteQueryDevtools } from "@tanstack/svelte-query-devtools";
import { useQueryClient } from "@tanstack/svelte-query";
const client = useQueryClient();
</script>
<!-- Basic usage with defaults -->
<SvelteQueryDevtools />
<!-- Custom positioning -->
<SvelteQueryDevtools
position="left"
buttonPosition="bottom-left"
/>
<!-- With error filtering -->
<SvelteQueryDevtools
errorTypes={[
{
name: "NetworkError",
initializer: (query) => new Error(`Network error in ${query.queryKey}`)
}
]}
/>
<!-- Custom client and CSP configuration -->
<SvelteQueryDevtools
{client}
styleNonce="your-csp-nonce"
hideDisabledQueries={true}
/>/**
* Position options for the devtools toggle button
* Template literal type combining Y and X positions, plus relative option
*/
type DevtoolsButtonPosition =
| 'top-left'
| 'top-right'
| 'bottom-left'
| 'bottom-right'
| 'relative';
/**
* Position options for the devtools panel
* Can be positioned on any edge of the screen
*/
type DevtoolsPosition = 'top' | 'bottom' | 'left' | 'right';
/**
* Configuration for error type filtering in devtools
*/
interface DevtoolsErrorType {
/** The name of the error type */
name: string;
/** Function that creates an error instance from a query */
initializer: (query: import('@tanstack/query-core').Query) => Error;
}
/**
* TanStack Query client interface
* Imported from @tanstack/svelte-query
*/
interface QueryClient {
// Core query client functionality
// See @tanstack/svelte-query documentation
}The component implements several important runtime behaviors:
DEV && BROWSER environment conditions are metuseQueryClient() by default to automatically access the query client from Svelte context$:) to update devtools configuration when props change@tanstack/query-devtools: Core devtools implementationesm-env: Environment detection utilities (DEV/BROWSER flags)@tanstack/svelte-query: TanStack Query Svelte integration (required for QueryClient and useQueryClient)svelte: Svelte framework (versions 3.54.0+, 4.x, or 5.x supported)