React Native & Expo errors · Error 12 of 12

Environment variables undefined in Expo / EAS builds

By Muhammad Abdullah, full-stack, mobile and ai automation developer · Last reviewed

process.env.EXPO_PUBLIC_… is undefined in an EAS build

Short answer

Expo only inlines variables whose names start with EXPO_PUBLIC_, and your local .env is often not part of the cloud build. Use the prefix, reference variables directly, and define them in EAS environment variables.

Common causes

  • The variable name lacks the EXPO_PUBLIC_ prefix.
  • Reading variables dynamically (process.env[name] or destructuring), which cannot be inlined.
  • The .env file is git-ignored, so it is not uploaded to EAS Build.

How to fix it

  1. Reference each variable directly:

                          const apiUrl = process.env.EXPO_PUBLIC_API_URL;
                        
  2. Create the variable for your build environment:

                          eas env:create --name EXPO_PUBLIC_API_URL --value https://api.example.com --environment production
                        
  3. Never put secrets in EXPO_PUBLIC_ variables — they are bundled into the app and visible to anyone.

Let’s talk about the next step

Have an idea, a stuck app, or a workflow toimprove?

Tell me what you are building, what is blocking you, and what a successful outcome looks like.