Open History to see the last commit
1---
2id: QueryClientProvider
3title: QueryClientProvider
4---
5β
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7β
8```ts
9function QueryClientProvider(props: QueryClientProviderProps): VNode;
10```
11β
12Defined in: [packages/preact-query/src/QueryClientProvider.tsx:69](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryClientProvider.tsx#L69)
13β
14Use the `QueryClientProvider` component to connect and provide a `QueryClient` to your application. Also
15calls `client.mount()`/`client.unmount()` as this component mounts/unmounts, which subscribes the client to
16focus/online events (resuming any paused mutations and refetching as needed when the app regains focus or
17comes back online).
18β
19## Parameters
20β
21### props
22β
23[`QueryClientProviderProps`](../type-aliases/QueryClientProviderProps.md)
24β
25The `client` to provide, and the `children` that get access to it.
26β
27<a id="props-properties"></a>
28β
29#### `props` properties
30β
31| Property | Type | Description |
32| ------ | ------ | ------ |
33| <a id="props-property-children"></a> `children?` | `ComponentChildren` | The components that get access to the provided `QueryClient`. |
34| <a id="props-property-client"></a> `client` | [`QueryClient`](../classes/QueryClient.md) | **Required** The `QueryClient` instance to provide. |
35β
36## Returns
37β
38`VNode`
39β
40The provided `children`, wrapped so they can read the `QueryClient` via `useQueryClient`.
41β
42## Example
43β
44```tsx
45import { QueryClient, QueryClientProvider } from '@tanstack/preact-query'
46β
47const queryClient = new QueryClient()
48β
49function App() {
50 return <QueryClientProvider client={queryClient}>...</QueryClientProvider>
51}
52```