Course contentsShow
← React Native
Lesson 98 of 1,5552. Project Scaffolding with ExpoFree lesson

Multi-Environment Deployment Strategies

Simultaneously maintain development, beta, and production release channels.

In this lesson, you will learn how to maintain separate development, beta, and production environments within your Expo project to ensure your users only see stable, tested code.

When you build a mobile application, it is dangerous to point your "development" build at your live production database or API. Instead, we use a strategy of environment isolation. By leveraging app.config.js (instead of the static app.json), you can dynamically inject different configurations—such as distinct bundle identifiers, app names, or API endpoints—based on the environment you are currently building for.

The Strategy

The core idea is to treat "Development," "Beta," and "Production" as three completely separate apps that happen to share the same codebase.

  1. Development: Used for your day-to-day coding. You might connect this to a mock API or a "sandbox" database.
  2. Beta (Staging): A mirror of production. This is where you test your final build, perform user acceptance testing, and verify your CI/CD pipelines work before going public.
  3. Production: The live version downloaded by your users.

In your app.config.js, you can use environment variables to switch these configurations on the fly:

export default ({ config }) => {
  const env = process.env.APP_ENV || 'development';
  
  return {
    ...config,
    name: env === 'production' ? 'My App' : `My App (${env})`,
    bundleIdentifier: `com.company.app.${env}`,
    extra: {
      apiUrl: env === 'production' ? 'https://api.myapp.com' : 'https://dev-api.myapp.com',
    },
  };
};

By changing the APP_ENV variable during your eas build process, you generate unique binaries. This allows you to have the "Dev," "Beta," and "Production" versions of your app installed on the same phone simultaneously without them overwriting each other. This keeps your local testing safe from your live user data, and it allows your QA team to test features in the "Beta" channel without interrupting your "Development" workflow.

Key Takeaway: By using dynamic configuration to assign unique bundle identifiers and API endpoints per environment, you can safely iterate on features without risking the stability of your production application.