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

README.md

14 lines1.1 KB

1# TanStack Query Angular SSR + persistence example
2​
3Combines [SSR/hydration](https://tanstack.com/query/latest/docs/framework/angular/guides/ssr), a `localStorage` persister, and a **client-only island**: `ClientPersistDemoComponent` is mounted with `afterNextRender`, so its `injectQuery` `queryFn` does not run during SSR (unlike `@defer` main content, which is still rendered on the server for incremental hydration).
4​
5- **Server:** same bootstrap config shape as the base SSR example; `withPersistQueryClient` uses a factory and skips work when not in the browser.
6- **Client:** `showClientDemo` is set to `true` in `afterNextRender`, then `<client-persist-demo />` is created β€” optional `dehydrateOptions.shouldDehydrateQuery` can scope persistence to `client-persist` query keys only.
7​
8To run:
9​
10- From the repo root: `pnpm install` then
11 `pnpm --filter @tanstack/query-example-angular-ssr-persist start`
12- Production SSR server after build:
13 `pnpm --filter @tanstack/query-example-angular-ssr-persist run build`
14 then `pnpm --filter @tanstack/query-example-angular-ssr-persist run serve:ssr`