Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
frontend ruleP2stack specificStack: react
ssrcontextisomorphic
Keep server-only context reads behind the SSR guard in isomorphic components
Data that only exists during the server render (streaming flags, request state) should stay behind `import.meta.env.SSR && useRequestResponse()` so the client bundle skips the read entirely, instead of being made nullable for everyone.
PR: hegnar-web#4698 FCK-3550 Drive ad suppression from the article flagCreated: Sep 7, 2026
Bad example
Old codets
| 1 | const isStreaming = useCtxOrNull()?.res.locals.streaming === true; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | const isStreaming = import.meta.env.SSR && useRequestResponse().res.locals.streaming === true; |
Explanation (EN)
Objašnjenje (HR)