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

QueryClientProvider.md

52 lines1.6 KB

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): Element;
10```
11​
12Defined in: [packages/solid-query/src/QueryClientProvider.tsx:100](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClientProvider.tsx#L100)
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?` | `JSX.Element` | 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`Element`
39​
40The provided `children`, wrapped so they can read the `QueryClient` via `useQueryClient`.
41​
42## Example
43​
44```tsx
45import { QueryClient, QueryClientProvider } from '@tanstack/solid-query'
46​
47const queryClient = new QueryClient()
48​
49function App() {
50 return <QueryClientProvider client={queryClient}>...</QueryClientProvider>
52```