Skip to Content
FrontendSetupMulti-Environments

Multi-Environments

There are 2 important environment variables to understand while working with NextJS application.

NODE_ENV

This variable determines the NextJS application environment. The allowed values for NODE_ENV are:

APP_ENV

This variables determines the deifferent environments configured on AWS environment. Possible values are:

  • dev: Corresponds to development environment and GitHub CICD branch is main
  • staging: Corresponds to staging environment and GitHub CICD branch is staging
  • prod: Corresponds to production environment and GitHub CICD branch is production

Loading APP_ENV variables

  • .env file contains the common variables between 3 environments.
  • environments/.env.* files contains the APP_ENV specific variables.
  • loadEnv.sh script is used before NextJS commands to load the correct APP_ENV specific variables into .env.local file. Checkout package.json scripts for more reference.

By default, APP_ENV is set to dev is not specified. However it can be set manually to different env before running npm command > APP_ENV=staging npm run dev

Last updated on