← All terms

Building a project

Environment variable

Environment variables supply named configuration to a program. A .env file is one way to load them. They can hold ordinary settings or secrets; the variable name alone does not control who receives the value.

You might see: env variable, dotenv, .env

In a real project

Your local app and deployed app can read different database URLs under the same variable name. You configure each environment separately instead of editing the application whenever its destination changes.

A common mistake

Assuming .env makes a value private. Committing the file exposes its contents, and framework prefixes such as NEXT_PUBLIC_ allow values to be bundled into browser code.

Put it into practice

These lessons open through your account. Your kit determines which are available.

Go to the source

Sources checked .