Docs
CodeRabbit
Cloudflare
AG Grid
SerpAPI
Netlify
OpenRouter
Neon
WorkOS
Clerk
Electric
PowerSync
Sentry
Railway
Prisma
Strapi
Unkey
CodeRabbit
Cloudflare
AG Grid
SerpAPI
Netlify
OpenRouter
Neon
WorkOS
Clerk
Electric
PowerSync
Sentry
Railway
Prisma
Strapi
Unkey
API Reference
API Reference

setQueryClientContext

ts
function setQueryClientContext(client: QueryClient): void;
function setQueryClientContext(client: QueryClient): void;

Defined in: packages/svelte-query/src/context.ts:42

Sets a QueryClient on Svelte's context, so it can be read with getQueryClientContext (or useQueryClient) from any descendant component. QueryClientProvider wraps this — use it directly only if you need to set the client from your own component instead.

Parameters

client

QueryClient

The QueryClient to make available to descendant components.

Returns

void

Example

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

  const queryClient = new QueryClient()
</script>

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

  const queryClient = new QueryClient()
</script>

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