Environment variables explained for beginners
What an environment variable is, why the same code behaves differently in two places, which ones reach the browser, and how to check whether yours is actually set.
Deployment turns source code into an app served at a public URL. Trace build failures, missing configuration and differences between preview and live.
Start with the guide that matches your question or the error you can see. Each guide below names the problem, gives checks you can run, and links to related reading.
Treat preview and live as separate environments until you verify otherwise. In an illustrative failure, preview has a server configuration value but the deployed environment does not. Rewriting the form will not supply that value. Check the failed request, deployed revision and target environment before changing application logic.
Public-variable prefixes expose values to browser code; they do not make secrets safe. Keep provider-designated secret credentials in server-side handlers. Use the environment-variable guide for visibility and scope, and the deployment walkthrough for the build-to-public-URL sequence. Do not print secrets into a build log while investigating.
What an environment variable is, why the same code behaves differently in two places, which ones reach the browser, and how to check whether yours is actually set.
From commit to live URL: install, build, output, edge and server functions, environment variables and why the production build is stricter than your laptop.
Looking for something else? Browse every topic.