Skip to content
PromptToProd

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.

Tools in this guide

ToolScoreFree tierPricing
Vercel86Yes: Hobby plan for personal, non-commercial projectsPro $20/seat/mo (includes $20 usage credit)
Netlify79Yes: 300 credits/mo hard limitPersonal $9/mo (1,000 credits); Pro from $20/mo (3,000 credits)
Railway80Partial: one-time $5 trial credit (30 days), then a Free plan with $1/mo creditHobby $5/mo (includes $5 usage)
Cloudflare Workers82Yes: 100,000 requests/dayWorkers Paid from $5/mo (10M requests included)
Supabase93Yes: 2 projects, 500 MB DB, 50K MAU, 1 GB storage (pauses after 1 week idle)Pro from $25/mo per org (includes $10 compute credit)

Scores come from our methodology. Money never affects them.

FAQ

Is it safe to put my Supabase key in a VITE_ variable?
Only the publishable (or legacy anon) key, and only with Row Level Security enabled. Never the secret or service_role key.
Why does my env var show up as undefined in production?
Most hosts need the variable set in their dashboard for that environment, and a redeploy after you add or change it. Client-side variables also need the framework prefix (VITE_ or NEXT_PUBLIC_).
What should I do if I committed an API key?
Rotate it immediately in the provider’s dashboard, update your host’s environment variable, redeploy and revoke the old key.

Sources

Related

PromptToProd Weekly

New tools, ranking changes and pricing updates. One email a week, unsubscribe anytime.

Prefer X? Follow @PromptToProdApp