Open History to see the last commit
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-async-storage-persister
9```
10β
11`@tanstack/query-async-storage-persister` provides the persister used below. Any
12other persister works as well.
13β
14## Usage
15β
16```ts
17import { QueryClient, provideTanStackQuery } from '@tanstack/angular-query'
18import { withPersistQueryClient } from '@tanstack/angular-query-persist-client'
19import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister'
20import type { ApplicationConfig } from '@angular/core'
21β
22export const appConfig: ApplicationConfig = {
23 providers: [
24 provideTanStackQuery(
25 () => new QueryClient(),
26 withPersistQueryClient(() => ({
27 persistOptions: {
28 persister: createAsyncStoragePersister({ storage: localStorage }),
29 },
30 })),
31 ),
32 ],
33}
34```
35β
36The factory runs only in the browser and inside an Angular injection context.
37This makes it safe to access browser-only storage and inject application
38services without sharing persistence state between SSR requests.