Skip to content

Environment Variables in Production — Never Hardcode Secrets

Learn how to manage environment variables across development, preview, and production environments on Vercel.

14 min readbeginner, hands-on, security, environment-variables, vercel

Earlier in this path, you created a .env.local file to keep secrets out of your code. That was the right move for local development. But now your app is deployed on Vercel, and the production environment introduces new complexities.

Different environments need different secrets. Your test Stripe key shouldn't process real credit cards. Your development database shouldn't be the same one serving real users. Getting this right is one of the most important things you'll do as you move from "my project works" to "my project is ready for users."

Why Different Environments Exist

Most applications run in at least three environments:

Development — Your laptop. The code you're actively working on. Uses test data, test API keys, and a development database.

Preview — Temporary depl

This lesson is part of the Guild Member curriculum. Plans start at $29/mo.