📄 tanstack/query/latest/docs/framework/svelte/overview

File: overview.md | Updated: 11/15/2025

Source: https://tanstack.com/query/latest/docs/framework/svelte/overview



TanStack

Query v5v5

Search...

+ K

Auto

Log In

TanStack StartRC

Docs Examples GitHub Contributors

TanStack Router

Docs Examples GitHub Contributors

TanStack Query

Docs Examples GitHub Contributors

TanStack Table

Docs Examples Github Contributors

TanStack Formnew

Docs Examples Github Contributors

TanStack DBbeta

Docs Github Contributors

TanStack Virtual

Docs Examples Github Contributors

TanStack Paceralpha

Docs Examples Github Contributors

TanStack Storealpha

Docs Examples Github Contributors

TanStack Devtoolsalpha

Docs Github Contributors

More Libraries

Maintainers Partners Support Learn StatsBETA Discord Merch Blog GitHub Ethos Brand Guide

Documentation

Framework

Svelte logo

Svelte

Version

Latest

Search...

+ K

Menu

Getting Started

API Reference

ESLint

Examples

Framework

Svelte logo

Svelte

Version

Latest

Menu

Getting Started

API Reference

ESLint

Examples

On this page

Overview

Copy Markdown

The @tanstack/svelte-query package offers a 1st-class API for using TanStack Query via Svelte.

Migrating from stores to the runes syntax? See the migration guide .

Example
-------

Include the QueryClientProvider near the root of your project:

svelte

<script lang="ts">
  import { QueryClient, QueryClientProvider } from '@tanstack/svelte-query'
  import Example from './lib/Example.svelte'

  const queryClient = new QueryClient()
</script>

<QueryClientProvider client={queryClient}>
  <Example />
</QueryClientProvider>


<script lang="ts">
  import { QueryClient, QueryClientProvider } from '@tanstack/svelte-query'
  import Example from './lib/Example.svelte'

  const queryClient = new QueryClient()
</script>

<QueryClientProvider client={queryClient}>
  <Example />
</QueryClientProvider>

Then call any function (e.g. createQuery) from any component:

svelte

<script lang="ts">
  import { createQuery } from '@tanstack/svelte-query'

  const query = createQuery(() => ({
    queryKey: ['todos'],
    queryFn: () => fetchTodos(),
  }))
</script>

<div>
  {#if query.isLoading}
    <p>Loading...</p>
  {:else if query.isError}
    <p>Error: {query.error.message}</p>
  {:else if query.isSuccess}
    {#each query.data as todo}
      <p>{todo.title}</p>
    {/each}
  {/if}
</div>


<script lang="ts">
  import { createQuery } from '@tanstack/svelte-query'

  const query = createQuery(() => ({
    queryKey: ['todos'],
    queryFn: () => fetchTodos(),
  }))
</script>

<div>
  {#if query.isLoading}
    <p>Loading...</p>
  {:else if query.isError}
    <p>Error: {query.error.message}</p>
  {:else if query.isSuccess}
    {#each query.data as todo}
      <p>{todo.title}</p>
    {/each}
  {/if}
</div>

SvelteKit
---------

If you are using SvelteKit, please have a look at SSR & SvelteKit .

Available Functions
-------------------

Svelte Query offers useful functions and components that will make managing server state in Svelte apps easier.

  • createQuery
  • createQueries
  • createInfiniteQuery
  • createMutation
  • useQueryClient
  • useIsFetching
  • useIsMutating
  • useMutationState
  • useIsRestoring
  • useHydrate
  • <QueryClientProvider>
  • <HydrationBoundary>

Important Differences between Svelte Query & React Query
--------------------------------------------------------

Svelte Query offers an API similar to React Query, but there are some key differences to be mindful of.

  • The arguments to the create* functions must be wrapped in a function to preserve reactivity.

Edit on GitHub

Discord

Installation

Partners Become a Partner

Code RabbitCode Rabbit CloudflareCloudflare AG GridAG Grid NetlifyNetlify NeonNeon WorkOSWorkOS ClerkClerk ConvexConvex ElectricElectric SentrySentry PrismaPrisma StrapiStrapi UnkeyUnkey

[###### Want to Skip the Docs?

Query.gg - The Official React Query Course
\

“If you’re serious about *really* understanding React Query, there’s no better way than with query.gg”—Tanner Linsley

Learn More](https://query.gg/?s=tanstack)

scarf analytics