Configuration and Environment variables

📡 What you will learn

  • Difference between development builds with expo-dev-client and Expo Go.
  • Configuring development and production variants in a managed project.
  • Using .env files to manage your environment variables.

👾 Before we start the exercise

  • Check this video to understand what is the difference between Expo Go and Expo Custom Development Client.

In this challenge we are going to put everything in place that you can have these variants on your app (Dev and production)

production variants in a managed project

👨‍🚀 Exercise 2

Following the documentation to add variants to your application:

  • create your app.config.js to use in your managed project
    • add a custom name for your dev app

Let's say now you want to have differents API endpoints. You can use environment variables to do that. Don't forget to follow the .env convention.

  • create a .env.local file and add your environment variables.
  • use process.env.EXPO_PUBLIC_API_URL to call the Star Wars API in your app.

In real situations, you may have multiple enpoints depending on the environment. Here is how you can set differents build profiles.

🔥 Never commit sensitive information!

If you want to store secret key in your repository like GOOGLE_MAPS_IOS_API_KEY, you can use EAS Secrets.

To create a new secret, run :

eas secret
eas secret:create  // create a new secret
eas secret:list    // view any existing secrets for this project
  • use eas secret:create and create a fake SWAPI_KEY because there is no API key for the Star Wars API.

In the next lesson, we are going to build your app and show you how to install it on your phone.