Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Detect the browser environment with `typeof window !== 'undefined'`
Use the standard `typeof window !== 'undefined'` guard instead of the legacy/removed `process.browser` flag.
Bad example
| 1 | const isClient = process.browser; |
Explanation (EN)
`process.browser` is a deprecated/removed Next.js-specific flag that is not part of any standard and can be undefined in modern setups.
Objašnjenje (HR)
`process.browser` je zastarjela/uklonjena zastavica specificna za Next.js koja nije dio nijednog standarda i moze biti undefined u modernim postavkama.
Good example
| 1 | const isClient = typeof window !== 'undefined'; |
Explanation (EN)
Checking `typeof window` is the standard, framework-agnostic way to detect whether code is running in the browser versus on the server.
Objašnjenje (HR)
Provjera `typeof window` je standardni, o frameworku neovisan nacin za otkrivanje izvrsava li se kod u pregledniku ili na serveru.