Environment variables in EAS
Edit page
An overview of how to use Expo Application Services (EAS) environment variables across builds, updates, and workflows.
This guide explains how to use Environment Variables in Expo Application Services (EAS): Build, Updates, Workflows, and Hosting. For general information on how environment variables work with the Expo framework, refer to Environment variables in Expo.
During a local development, environment variables are loaded from your local .env or .env.local files. These files are generally excluded from the project's version control (that is, if they are listed in the .gitignore file or not committed) so they are not available for jobs that run on a remote server, for example, EAS Build and EAS Workflows. Additionally, most projects have multiple app variants and require multiple sets of environment variables (for instance Development and Production).
Why use EAS environment variables
You might want to use EAS Environment Variable if you need to:
- Keep configuration in one place for cloud builds, updates, and workflows without committing .env files.
- Separate values by environment (
development,preview,production) while reusing names. - Control visibility (plain text, sensitive, secret) so only the right surfaces can read each value.
- Apply the same set locally with
eas env:pullor inside CI/CD.
These are the problems that EAS Environment variables is built to solve. With EAS Environment variables, the variables are configured in EAS via the EAS CLI or directly on the expo.dev dashboard, and can be accessed by EAS Build and EAS Workflows as well as your local machine via the EAS CLI.
Quick start
1
To create a new environment variable, use the EAS CLI and run the following command inside your project directory. The following command creates a new environment variable with the name EXPO_PUBLIC_API_URL and the value https://api.example.com for the production environment.
- eas env:create --name EXPO_PUBLIC_API_URL --value https://api.example.com --environment production --visibility plainText2
Verify if the environment variable is created successfully by confirming it appears with the production badge in the Environment variables in your project settings. Environment variables can also be managed directly on expo.dev.
3
To use the environment variable in EAS Build, add environment field to the prodcuction build profile:
{ "build": { "production": { "environment": "production" } } }
Now, any environment variables created for the production build profile will be available during the build process.
4
To use the environment variable with EAS Update, run the eas update command with the --environment flag specified:
- eas update --environment productionThe --environment flag is used to specify the environment to use for the update job. Only the environment variables from the specified environment will be used during the update process.
5
To use the environment variable with EAS Hosting, run the eas deploy command with the --environment flag specified. If you need both client and server side environment variables, run the commands below in the order they are listed (client-side variables must be plain text or sensitive, not secret) and see client-side environment variables for details information.
- eas env:pull --environment production- npx expo export --platform web- eas deploy --environment productionThe --environment flag is used to specify the environment to use for the deploy job. Only the environment variables from the specified environment will be used during the deploy process.
Key concepts
Available environments
By default, EAS supports three environments for environment variables: development, preview, and production environments. Custom environment names are available on Enterprise and Production plans.
Each environment is an independent set of variables that can be used to customize your app in different contexts. For example, you can use different API keys for development and production, or use different bundle identifiers for app store releases.
Every EAS Build and Workflows job runs using environment variables from one of the available environments. You can also use environments for updates, allowing you to use the same set of environment variables for your build jobs. You can do this when publishing an update by providing the --environment flag.
Environment variables can be assigned to multiple environments and have the same value across all of them, or be created for a single environment.
Scope
- Project-wide: Specific to a single EAS project. You can create, view, and manage them by navigating to the Environment variables page in your project's dashboard. These environment variables are available in any jobs that run on EAS servers and updates for this project. They can also be pulled locally for development if their visibility setting allows it.
- Account-wide: Available across all projects in your EAS account. You can create, view, and manage them by navigating to the Environment variables page in your account's dashboard. These environment variables are available in jobs that run on EAS servers and updates, together with project-wide variables for a project. You can pull them locally or read outside of EAS servers if their visibility setting allows it.
Variable types
- Strings: Standard key/value pairs that can be used across builds, updates, workflows, and hosting.
- Files: Values uploaded as files (for example,
google-services.jsonor a certificate) that are made available to jobs as file paths on the build runner.
Visibility settings for environment variables
There are three different visibility settings available for each environment variable:
| Visibility | Description |
|---|---|
| Plain text | Visible on the website, in EAS CLI, and in logs. |
| Sensitive | Obfuscated in EAS Build and Workflows job logs. You can use a toggle to make them visible on the website. They are also readable in EAS CLI. |
| Secret | Not readable outside of the EAS servers, including on the website and in EAS CLI. They are obfuscated in EAS Build and Workflows job logs. |
Note that anything that is included in your client side code should be considered public and readable to any individual that can run your app.
Secret type environment variables are intended to provide values to an EAS Build or Workflows job so that they may be used to alter how a job runs. For example, setting anNPM_TOKENto install private packages from npm, or a setting a Sentry API key to create a release and upload your source maps. Secrets do not provide any additional security for values that you end up embedding in your application itself.
Where to go next
Learn how to create, scope, and consume environment variables with EAS dashboard and EAS CLI.
Learn how to use environment variables in EAS builds, updates, hosting, and workflow jobs.
Learn about non-EAS ways to manage environment variables in Expo and React Native projects.
Frequently asked questions about environment variables in EAS.