Open History to see the last commit
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`