Create and manage environment variables in EAS

Edit page

Learn how to create, scope, and consume environment variables with EAS dashboard and EAS CLI.


The following sections cover how to create, scope, and consume environment variables with EAS dashboard and EAS CLI.

Create environment variables

  • Choose an environment or multiple environments: development, preview, and production are available by default. A variable can be reused across them or customized per environment.
  • Choose scope: Project-wide variables apply to one project. Account-wide variables can be reused across projects and are merged with project variables at build time.
  • Choose visibility: Use secret for values that should never leave EAS servers, sensitive for values that may be revealed locally, and plain text for non-sensitive values.

Create variables in the dashboard

To create a new environment variable on EAS servers, in your project dashboard, you can navigate to the Project settings > Environment variables and then click on the Add Variables button.

Use the environment variables creation form page to set the name, value, environment(s), visibility, and optional description.

Created variables appear in the list with their scope, visibility, and environment tags. Based on the environment variables in this example, the list may look like this:

In the above example list:

  • The SENTRY_AUTH_TOKEN variable is a sensitive environment variable. It is used to authenticate Sentry to upload source maps after builds and updates, and has to be accessible outside of EAS servers.
  • The GOOGLE_SERVICES_JSON variable is a secret environment variable and uses an uploaded file. It is used to authenticate Google to access the Google Services JSON file, and has to be stored securely on EAS servers. This uploaded JSON file is typically added to your project's .gitignore.
  • All other variables, such as APP_VARIANT and EXPO_PUBLIC_API_URL, are plain text environment variables.

Create variables with EAS CLI

Use eas env:create to add variables and eas env:list to verify what is set.

Terminal
# Example to create a new plain text environment variable for the preview environment
eas env:create --name EXPO_PUBLIC_API_URL --value https://example.app/staging --environment preview --visibility plaintext

# Example to list all environment variables for the preview environment
eas env:list --environment preview

Using environment variables in your code

Client-side values

The environment variables with the EXPO_PUBLIC_ prefix are available as process.env variables in your app's code. You can use them dynamically to configure your app behavior based in their values:

import { Button } from 'react-native'; function Post() { const apiUrl = process.env.EXPO_PUBLIC_API_URL; async function onPress() { await fetch(apiUrl, { %%placeholder-start%%... %%placeholder-end%% }); } return <Button onPress={onPress} title="Post" />; }

In above example, EXPO_PUBLIC_API_URL is used to dynamically set the API URL for the fetch request.

Do not put secrets in EXPO_PUBLIC_ variables. Everything in client bundles is readable by end users.

Build-time and app config

Other variables that are without EXPO_PUBLIC_ prefix, can be used during app config resolution to configure your app's behavior. For example, the APP_VARIANT variable is used to determine the app name, package name, and bundle identifier for the selected app variant:

Use non-prefixed variables in dynamic app config. Keep visibility at least sensitive if you need to resolve config locally (plain text and sensitive are readable in EAS CLI; secrets stay on the server).

app.config.js
const IS_DEV = process.env.APP_VARIANT === 'development'; const IS_PREVIEW = process.env.APP_VARIANT === 'preview'; const getUniqueIdentifier = () => { if (IS_DEV) { return 'com.yourname.stickersmash.dev'; } if (IS_PREVIEW) { return 'com.yourname.stickersmash.preview'; } return 'com.yourname.stickersmash'; }; const getAppName = () => { if (IS_DEV) { return 'StickerSmash (Dev)'; } if (IS_PREVIEW) { return 'StickerSmash (Preview)'; } return 'StickerSmash: Emoji Stickers'; }; export default { name: getAppName(), %%placeholder-start%%... %%placeholder-end%% ios: { bundleIdentifier: getUniqueIdentifier(), %%placeholder-start%%... %%placeholder-end%% }, android: { package: getUniqueIdentifier(), %%placeholder-start%%... %%placeholder-end%% }, };

Secrets and file variables

Environment variables such as GOOGLE_SERVICES_JSON is a secret file variable that is not readable outside of EAS servers and is used to provide the git ignored google-services.json file to an EAS Build job. To use it in the app config, you can use the process.env variable and provide a fallback value in case the variable is not set (for local development when you usually have it inside your project's repository):

app.config.js
export default { android: { googleServicesFile: process.env.GOOGLE_SERVICES_JSON ?? '/local/path/to/google-services.json', }, };

Manage environment variables

You can use EAS dashboard in your project or account to create, update, and delete environment variables.

You can also use EAS CLI to manage them. The following commands are provided as examples for production environment. When using these commands, replace production with the environment you want to manage.

Terminal
# To create a new environment variable
eas env:create --name EXPO_PUBLIC_API_URL --value https://example.app/staging --environment production --visibility plaintext

# To update an existing environment variable
eas env:update --name EXPO_PUBLIC_API_URL --value https://example.app/staging --environment production --visibility plaintext

# To delete an existing environment variable
eas env:delete

# To list all environment variables
eas env:list --environment production

# To pull environment variables into a .env file
eas env:pull --environment production
Tip: See the EAS CLI command reference for more information about the above commands.

Pull variables for local development

The efficient way to use EAS environment variables for local development is to pull them into a .env file using the eas env:pull --environment environment-name command:

For example, to pull the environment variables for the production environment into a .env file, you can run:

Terminal
eas env:pull --environment production

The created file may look like the following:

.env.local
# Environment: production APP_VARIANT=development EXPO_PUBLIC_API_URL=https://staging.my-api-url.mycompany.com # GOOGLE_SERVICES_JSON=***** (secret variables are not available for reading) SENTRY_AUTH_TOKEN=token
Tip: Keep generated .env files in .gitignore to avoid leaks and precedence conflicts between local and cloud jobs.

You can also use the Export option in the EAS dashboard to download the file and store it inside your project.

Custom environments

Creating custom environments is available for Enterprise and production plans.

The three default environments are sufficient for most use-cases, but if you project relies on complex workflows and requires the flexibility to create more environments, using custom environments may come in handy.

Create a custom environment in EAS dashboard

To create a custom environment in EAS dashboard:

  • In your project, navigate to the Project settings > Environment variables and then click on the Add Variables button.
  • Under Environments, click the plus (+) icon to enter a name for a custom environment.
  • After creating the environment, it will be pre-selected under the Custom environments section.
  • As long as there is at least one environment variable linked to this environment, it will show up as a selectable option for all environment variables for that account or project.

Create a custom environment with EAS CLI

To assign an environment variable to a custom environments, use your custom environment name in place of the environment. For example, the command below creates a new variable EXPO_PUBLIC_API_URL and assigns it to the custom staging environment:

Terminal
eas env:create --name EXPO_PUBLIC_API_URL --value https://example.app/staging --environment staging --visibility plaintext