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 buildShort 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
.envfile is git-ignored, so it is not uploaded to EAS Build.
How to fix it
Reference each variable directly:
const apiUrl = process.env.EXPO_PUBLIC_API_URL;Create the variable for your build environment:
eas env:create --name EXPO_PUBLIC_API_URL --value https://api.example.com --environment productionNever put secrets in
EXPO_PUBLIC_variables — they are bundled into the app and visible to anyone.