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