Next.js comes with built-in support for environment variables, which allows you to do the following:
* Expose environment variables to the browser by prefixing with
NEXT_PUBLIC_
Default Environment Variables : In general only one .env.local
file is needed. However, sometimes you might want to add some defaults for the development
(next dev
) or production
(next start
) environment.
Next.js allows you to set defaults in .env
(all environments), .env.development
(development environment), and .env.production
(production environment).
.env.local
always overrides the defaults set.