Environment variables and secrets for vibe-coded apps
Checked against official pricing pages and docs on Oct 26, 2026. Plans change, so confirm on each official site.
Every vibe-coded app ends up with keys: a database URL, an auth key, a Stripe key, an LLM API key. Some are meant to be public, most are not. The rule is simple once you know how your framework decides what ends up in the browser.
Public vs secret: the one question
Ask where the code runs. Code that ships to the browser or a mobile app can be read by anyone, so it may only use keys designed to be public (a Supabase publishable key, a Stripe publishable key, an analytics site ID). Code you control (a server, an edge function, a cron job) can hold secret keys. Supabase’s own docs frame key choice exactly this way.
How frameworks expose variables
Vite (used by Lovable and Bolt projects): variables prefixed with VITE_ are exposed in client-side code after bundling, so never put a secret behind that prefix. Next.js: variables prefixed with NEXT_PUBLIC_ are inlined into the browser bundle; everything else stays server-only. If an agent writes VITE_OPENAI_API_KEY or NEXT_PUBLIC_STRIPE_SECRET_KEY, stop and move that call to the server.
Keep .env files out of git
Put .env and .env.local in .gitignore and commit a .env.example with empty values instead. GitHub push protection blocks many known secret formats, but treat it as a safety net, not the plan.
Set secrets on your host
Every host has an environment-variables screen: Vercel lets you scope variables to Production, Preview and Development; Netlify, Railway and Cloudflare Workers have their own equivalents. Use separate keys for preview and production, and redeploy after changing a variable so the new value is picked up.
If a key leaks
Rotate it first, then clean up. Create a new key in the provider’s dashboard, update it on your host, redeploy, then revoke the old key. Removing the key from git history does not help if it was already pushed: assume it was copied.