Get started with Svelte Query by installing the package and setting up your application.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tanstack/query/llms.txt
Use this file to discover all available pages before exploring further.
Requirements
Svelte Query requires:- Svelte 5.25.0 or higher - Uses modern Svelte 5 runes (
$state,$derived,$effect) - TypeScript 4.7+ (recommended) - For full type safety
- Node.js 18+ - For development
Installation
Install the package
Install This will install
@tanstack/svelte-query using your preferred package manager:@tanstack/svelte-query version 6.0.18 or higher, which includes:- Core query functionality
- TypeScript type definitions
- Svelte 5 rune-based reactivity
Set up the QueryClientProvider
Create a
QueryClient and wrap your application with QueryClientProvider in your root layout:+layout.svelte
In SvelteKit applications, place this in your root
+layout.svelte file to make the QueryClient available throughout your app.Configuration Options
TheQueryClient accepts various configuration options to customize its behavior:
Common Configuration Patterns
SvelteKit Integration
For SvelteKit applications, you may want to handle browser-specific features:+layout.svelte
Optional: Install DevTools
For development, install the Svelte Query DevTools to visualize and debug your queries:+layout.svelte
The DevTools only render in development mode and are automatically tree-shaken from production builds.
Package Dependencies
Svelte Query has a minimal dependency footprint:package.json
@tanstack/query-core- Framework-agnostic core query logicsvelte- Required peer dependency (version 5.25.0+)
Troubleshooting
Error: “Svelte version 5.25.0 or higher is required”
Ensure you have Svelte 5.25.0+ installed:Error: “Cannot find QueryClient in context”
Make sure you’ve wrapped your app withQueryClientProvider:
TypeScript errors with runes
Ensure yourtsconfig.json is configured for Svelte 5:
tsconfig.json
Next Steps
Quick Start Guide
Learn the basics with a step-by-step tutorial.Quick Start →
TypeScript Configuration
Set up TypeScript for maximum type safety.TypeScript Guide →
Configure DevTools
Learn how to use the Svelte Query DevTools.DevTools Setup →