FULL AI ANALYSIS

Angular SSR hydration mismatch — server HTML differs from client and interactive bindings fail

Generated Nov 7, 2026, 9:46:16 AM

Analysis summary

Hypotheses: (1) Non-deterministic expressions (Date.now(), Math.random(), locale-sensitive formatting) in templates cause differing server/client HTML; (2) Direct DOM or window use in template or component lifecycle runs only client-side leading to mismatch; (3) Async data resolution order differs between server and client; (4) Missing TransferState for server-fetched data causes the client to re-request and re-render.

Possible causes

Template-bound non-deterministic values (Date.now, Math.random, locale formatting) produce different server vs client HTML (hypothesis).

9%

Component logic runs differing code paths under isPlatformBrowser checks, causing different node structure (hypothesis).

7%

Server rendered placeholder values while client fetches data and replaces nodes because TransferState not used (hypothesis).

6%

Third-party components mutate DOM during client bootstrap causing mismatch (hypothesis).

5%

Suggested fixes

1

Diagnostic step 1

Save the exact server-rendered HTML (view-source: or curl the SSR endpoint) and, immediately after client boot, dump document.documentElement.outerHTML in the browser console. Diff the two outputs. Result meaning: If serialized HTML differs (timestamps, IDs, text nodes), identify which template expressions produced the difference. If identical but behavior diverges, issue is likely runtime-only (event binding).

2

Diagnostic step 2

Search templates and components for uses of Date, Math.random, Intl.DateTimeFormat or direct window/document access and temporarily replace with deterministic constants to test. Result meaning: If replacing these expressions removes the mismatch, non-determinism was the cause. If not, continue searching for other differences.

3

Diagnostic step 3

Instrument server rendering to include a hash of rendered root HTML (e.g., sha1) and have client compute same hash early in bootstrap to compare determinism. Result meaning: If hashes differ, server/client output differs; the diff can point to offending nodes. Matching hashes mean initial DOM matches and problem occurs later during hydrating bindings.

4

Diagnostic step 4

Enable TransferState for server-fetched async data and ensure client reads TransferState instead of re-fetching on bootstrap. Compare network panel to ensure client skips requests. Result meaning: If client still requests data, TransferState wasn't wired; that will cause re-rendering and mismatch. If client doesn't request, data parity likely OK.

5

Diagnostic step 5

Temporarily stub third-party components (replace with no-op) and retry SSR hydrate. Result meaning: If mismatch disappears, library mutates DOM or uses browser-only APIs causing differences; update or lazy-load such components.