Environment variables and secrets

Settings that live outside your code, the two vaults, and what to do if a key leaks.

An environment variable is a named setting kept outside your code — like NEXT_PUBLIC_SUPABASE_URL, the address of your database. Your code says "use whatever NEXT_PUBLIC_SUPABASE_URL is"; the actual value is filled in where the code runs.

Some are harmless (an address); some are secrets (passwords, keys) that would let someone read or change your data.

The two vaults

Vault Holds Used by Examples
Vercel → Settings → Environment Variables What your website needs to run Your live site and previews NEXT_PUBLIC_SUPABASE_URL, NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY
GitHub → Settings → Secrets and variables → Actions What your automations need Backups, restores, database changes SUPABASE_DB_URL, SUPABASE_SECRET_KEY, BACKUP_PASSPHRASE

.env.example in your project lists the names the app needs — never values.

The rules

  • Never put a secret in your project files, in a chat with your agent, or in PROJECT.md. Your agent will tell you which vault and which name; you paste the value there yourself.
  • Names starting with NEXT_PUBLIC_ end up in the browser — only use them for values that are safe to be public.
  • The Any secrets leaked? check scans every pull request for keys.

If a key leaks

Deleting it from the file isn't enough — it stays in your project's history. Replace ("rotate") it where it came from (e.g. Supabase → API Keys, or reset the database password), then update the new value in the vault. Ask your agent to run doctor afterwards.