Performance: Environment variables in production
MEDIUM IMPACT
This affects page load speed and security by controlling what data is exposed to the client and how the server handles configuration.
module.exports = { env: { NEXT_PUBLIC_API_KEY: process.env.NEXT_PUBLIC_API_KEY } }; // Keep SECRET_KEY only on server side and access via server code
module.exports = {
env: {
NEXT_PUBLIC_API_KEY: process.env.NEXT_PUBLIC_API_KEY,
NEXT_PUBLIC_SECRET_KEY: process.env.NEXT_PUBLIC_SECRET_KEY
}
};| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Exposing all env vars to client | N/A | 0 | Increased due to larger JS bundle | [X] Bad |
| Exposing only NEXT_PUBLIC_ vars | N/A | 0 | Minimal paint cost, smaller JS bundle | [OK] Good |