Environment Variables

Learn how to use environment variables in your Next.js project.

The starter project comes with two different environment variables files:

  1. .env: the main environment file - use this for variables that are common to all environments - and that are not secrets.
  2. .env.development: the development environment file (used when running the project locally in development mode) - when they're specific to the development environment.
  3. .env.production: the production environment file (used when deploying or running the build command) - when they're specific to the production environment.
  4. .env.local: this environment file is loaded when running the project locally. It won't be committed to Git. Useful for adding secrets that you don't want to commit to Git.
  5. .env.test: this environment file is loaded when running the Cypress E2E tests. You would rarely need to use this.

Subscribe to our Newsletter
Get the latest updates about React, Remix, Next.js, Firebase, Supabase and Tailwind CSS