CodeZettaInterview Hub

Angular · SSR · Senior · Debugging

How do you avoid breaking SSR with window/document usage?

Short Interview Answer

Guard with isPlatformBrowser, inject DOCUMENT carefully, or move code to afterNextRender.

Detailed Explanation

Using window at import/constructor time crashes SSR. Prefer abstracting browser APIs behind services.

Did you know this answer?