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: Vite
viteenvconfigurationtypes
Read env vars via import.meta.env in Vite and declare their types
In Vite projects access environment variables through import.meta.env to match how Vite exposes them, and add the typings to vite-env.d.ts for type safety.
PR: hegnar-bellsheep-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codets
| 1 | const url = process.env.VITE_API_URL; // not how Vite exposes vars to the client |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | const url = import.meta.env.VITE_API_URL; // + declare in vite-env.d.ts |
Explanation (EN)
Objašnjenje (HR)