Performance: Environment variables management
MEDIUM IMPACT
This affects page load speed and bundle size by controlling which variables are included in the build and exposed to the client.
// Only expose variables prefixed with VITE_ in .env files const apiKey = import.meta.env.VITE_API_KEY; // Keep secrets only on server side, not imported in client code console.log(apiKey);
// Using many environment variables directly in client code without filtering const apiKey = import.meta.env.VITE_API_KEY; const secretKey = import.meta.env.VITE_SECRET_KEY; // accidentally exposed secret console.log(apiKey, secretKey);
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Exposing all env variables including secrets | 0 (no DOM impact) | 0 | 0 | [X] Bad |
| Exposing only VITE_ prefixed variables | 0 (no DOM impact) | 0 | 0 | [OK] Good |