DevOpsintermediate

Environment Variables

Secret configuration values (like API keys) stored outside your code.

Detailed Explanation

Environment variables are configuration values stored outside your source code, typically in a .env file. They are used for secrets (API keys, database passwords) and configuration that changes between environments (development vs. production).

Never commit .env files to Git — they contain sensitive tokens and keys. Add .env to your .gitignore file. In React apps using Vite, environment variables must start with VITE_ to be available in frontend code. Backend variables (like service role keys) should only be used in Edge Functions.

Supabase requires two environment variables: your project URL and your anon key. If these are missing or wrong, your loaders and actions will fail — typically with a network error visible in the Network Tab of DevTools or a CORS error in the console. Always restart your dev server after changing .env values. Claude Code automatically sets up .env files and ensures secrets are stored correctly. Encrypted secrets can also be stored in your hosting platform's dashboard.

Cloud platforms like Google Cloud Run use environment variables to tell your app which Port to listen on (via the PORT variable), in addition to storing secrets like API Keys.

Code Example

bash

Ready to Build Something Real?

We give you the skills to build, deploy, and own a full product. Professional stack, AI co-pilot, no coding background required.