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

README.md

33 lines899 Bytes

1# @tanstack/angular-query-persist-client
2​
3Persistence integration for `@tanstack/angular-query`.
4​
5## Installation
6​
7```sh
8pnpm add @tanstack/angular-query-persist-client @tanstack/query-persist-client-core
9```
10​
11## Usage
12​
13```ts
14import { QueryClient, provideTanStackQuery } from '@tanstack/angular-query'
15import { withPersistQueryClient } from '@tanstack/angular-query-persist-client'
16​
17export const appConfig: ApplicationConfig = {
18 providers: [
19 provideTanStackQuery(
20 () => new QueryClient(),
21 withPersistQueryClient(() => ({
22 persistOptions: {
23 persister: createAsyncStoragePersister({ storage: localStorage }),
24 },
25 })),
26 ),
27 ],
29```
30​
31The factory runs only in the browser and inside an Angular injection context.
32This makes it safe to access browser-only storage and inject application
33services without sharing persistence state between SSR requests.