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 ruleP1universalStack: any
configurationlibraryenvcomponent-design
Pass runtime config to shared components as props, not build-time env vars
A reusable/published package can't bake environment URLs at its own build time; expose them as props/attributes so each consuming app supplies its own values.
PR: hegnar-components · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | const apiUrl = import.meta.env.VITE_WS_URL; // frozen at the library's build time |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | function Widget({ apiUrl }: { apiUrl: string }) { |
| 2 | // host app injects the right URL per environment |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)