FRONT002errorPro

window-ssr-unsafe

Accessing window/document without SSR check causes server-side errors

Applies to: JavaScript, TypeScript

Why this matters

In Next.js, Nuxt, and other SSR frameworks, code runs on both server and client. The 'window' and 'document' objects only exist in browsers, so accessing them during server-side rendering causes 'window is not defined' errors. Always check typeof window !== 'undefined' before accessing browser APIs, or use useEffect/onMounted.

Catch it before it ships

pip install stablestack # or: npx stablestackstablestack # scans your project, FRONT002 includedstablestack explain FRONT002

FRONT002 is part of the Pro rule set. See pricing — the free tier ships 24 checks with no signup.

False positive in your codebase? Suppress a single line with # noqa: FRONT002