Vibe Code Forum teamAdmin
Your app needs secrets: API keys, database passwords, payment keys. They must never be written into your code, because code gets shared, committed to GitHub, pasted into chats and shipped to browsers. Environment variables keep them separate.
What they are
An environment variable is a named setting that lives outside your code, such as OPENAI_API_KEY=sk-.... Your code reads it by name (process.env.OPENAI_API_KEY in Node, os.environ["OPENAI_API_KEY"] in Python), so the value never appears in the files.
On your computer: the .env file
Most projects use a file called .env in the project folder:
DATABASE_URL=postgres://...
STRIPE_SECRET_KEY=sk_test_...
Two rules:
.envmust be listed in.gitignorebefore your first commit, so Git never saves it.- Commit a
.env.examplewith the same names and empty or fake values, so you (and your AI tool) know what the project needs.
On your host
Hosting platforms have an "Environment variables" settings page. Add the same names and real values there. After changing them, redeploy, because most platforms only read them when building or starting. See Vercel, Netlify and friends.
Browser variables are not secret
Front-end frameworks let some variables reach the browser on purpose, usually ones whose names start with a prefix such as NEXT_PUBLIC_, VITE_ or EXPO_PUBLIC_. Anyone can read those by opening the page source. Use them only for values that are meant to be public, such as a Supabase anon key or an analytics ID. If the AI puts a secret key in one of these, stop and ask it to move that call to the server.
Quick checks
- Search your project for
sk-,secretandkeybefore pushing. - Ask your AI tool: "Is any secret key used in front-end code or committed to Git?"
- If a key ever leaks, revoke it at the provider immediately. See I pushed my API key to GitHub.