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).
fullstack ruleP2project specificStack: react
nextjsenv-varsconfiguration
Expose client env variables via the framework prefix, not a custom context
Use NEXT_PUBLIC_ (framework-provided client env prefix) to expose values to the browser instead of building a bespoke env-passing mechanism.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetsx
| 1 | <EnvVariablesContext.Provider value={{ apiUrl: serverEnv.API_URL }}> |
| 2 | {children} |
| 3 | </EnvVariablesContext.Provider> |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const apiUrl = process.env.NEXT_PUBLIC_API_URL; |
Explanation (EN)
Objašnjenje (HR)