Environment variables

.env files

Turbopack will parse and inject .env files out of the box.

NEXT_PUBLIC_DEPLOYMENT_NAME="my-site"
DATABASE_URL="postgres://"

This includes all the variations these files come in:

.env
.env.local
.env.development
.env.production.local

Live reloading

Not only that, but Turbopack will live reload when these values change. Restarting your dev server just to inject a new environment variable can be extremely annoying - Turbopack does it for you.

process.env

Environment variables will be injected into process.env. For instance, DATABASE_URL will be on process.env.DATABASE_URL.

This follows the tradition of Node.js, Webpack 5 and Next.js 12, which each use process.env for variable injection.

Last updated on 2022-10-23T18:47:10.000Z