Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

setQueryClientContext.md

42 lines1.0 KB

1---
2id: setQueryClientContext
3title: setQueryClientContext
4---
5​
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7​
8```ts
9function setQueryClientContext(client: QueryClient): void;
10```
11​
12Defined in: [packages/svelte-query/src/context.ts:42](https://github.com/TanStack/query/blob/main/packages/svelte-query/src/context.ts#L42)
13​
14Sets a `QueryClient` on Svelte's context, so it can be read with [getQueryClientContext](getQueryClientContext.md) (or
15[useQueryClient](useQueryClient.md)) from any descendant component. `QueryClientProvider` wraps this β€” use it directly
16only if you need to set the client from your own component instead.
17​
18## Parameters
19​
20### client
21​
22[`QueryClient`](../classes/QueryClient.md)
23​
24The `QueryClient` to make available to descendant components.
25​
26## Returns
27​
28`void`
29​
30## Example
31​
32```svelte
33<script lang="ts">
34 import { QueryClient, QueryClientProvider } from '@tanstack/svelte-query'
35​
36 const queryClient = new QueryClient()
37</script>
38​
39<QueryClientProvider client={queryClient}>
40 ...
41</QueryClientProvider>
42```