How to add environment variables to app.json file

Viewed 411

I have an app.json file in my Expo project. In this file I have two API keys (labeled API_KEY below) that I'd like to hide via environment variables.

How can I go about using environment variables instead of hard coding the API keys?

app.json

{
  "expo": {
    "name": "Closeout",
    "slug": "Closeout",
    "version": "1.0.0",
    "orientation": "portrait",
    "privacy": "hidden",
    "notification": {
      "icon": "./assets/images/notification-icon.png",
      "color": "#000000",
      "iosDisplayInForeground": true
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": ["**/*"],
    "ios": {
      "icon": "./assets/images/icon.png",
      "buildNumber": "2",
      "config": {
        "googleMapsApiKey": "API_KEY"
      }
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/images/icon.png",
        "backgroundColor": "#000"
      },
      "versionCode": 5,
      "useNextNotificationsApi": true,
      "config": {
        "googleMaps": {
          "apiKey": "API_KEY"
        }
      },
      "googleServicesFile": "./google-services.json"
    }
  }
}
0 Answers
Related