Environment variables eas development client

Hi,

I have recently switched over to EAS and have created a build for a dev client with the following config

"build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal",
      "releaseChannel": "development",
      "env": {
        "API_URL": "foo",
      },
      "ios": {
        "autoIncrement": true,
        "simulator": true
      }
    },
}

I have successfully built the client and installed it on my iOS simulator.

The problem I am having is accessing the Environment variables.

I have them in a .env file with matching keys in the eas.json

But when I try to access the process.env.API_URL I get undefined.

If I log out my env object it looks like this

{
  "NODE_ENV": "development",
}

I have not used an extra object in my app.json/app.config.js as I have moved over to EAS.
If I use an extra object as per the docs I can access the variables via expo-constants.

Can someone please advise where I am going wrong?

  • Managed workflow
  • eas-cli version eas-cli/0.41.1

I have tried creating new builds of the dev client and creating a build for production testflight and the app still crashes unable to access environment variables.

hello! please refer to these docs for more info on how env vars work: Environment variables and secrets - Expo Documentation

i believe your particular issue is addressed here: Environment variables and secrets - Expo Documentation

@notbrent thanks for this!

I have changed to using a Config.js for my dev client build and can read values from there fine.

I am still confused though about secrets.

I would not want this part of my application code and would want to read these from environment values.

For local dev is it advised to use an app.config.js?

And how would I read secrets defined in expo within my Config.js?

eg. I have a stripe key stored as a secret which I do not want in my code (not committed to git) and will I use eas with the secret and the config.js file?

Figured out my issue, had to use react-native-dotenv in my config.js

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.