How to Manage Multiple Environments in AppsOnAir CodePush?

By Samarth Sheth
Dot
March 7, 2025
Blue graphic with text reading "Manage Multiple Environments." The background features a digital globe and connectivity icons (Wi-Fi, locks). A cloud upload logo is in the bottom-right corner.

After migrating to AppsOnAir CodePush, you might notice that only a Production deployment is generated by default.

Unlike App Center, which automatically creates both Staging and Production deployments, AppsOnAir simplifies the process by allowing you to configure your environments manually.

‍

The Best Approach: Separate Apps for Staging & Production

AppsOnAir CodePush associates deployments with specific apps. To manage multiple environments effectively, follow these steps:

‍

Step 1: Create a Staging App

Log in to the AppsOnAir Portal and create a new app. Name it something like “MyApp-Staging” to designate it as your staging environment.

‍

Step 2: Retain Your Production App

Your existing app (e.g., MyApp) remains your Production version, where only stable updates are deployed.

‍

Step 3: Configure Deployment Keys in Your Code

Now, in your app's code, use different deployment keys for each environment, such as staging and production.

‍

Environment Variables

Define the deployment keys in an .env file or configuration file:

CODEPUSH_KEY_STAGING=your-staging-deployment-key 
CODEPUSH_KEY_PRODUCTION=your-production-deployment-key

‍

App Configuration (React Native)

Modify your app’s initialization to dynamically load the appropriate deployment key:

import CodePush from 'react-native-code-push';
const deploymentKey = __DEV__ ? process.env.CODEPUSH_KEY_STAGING : process.env.CODEPUSH_KEY_PRODUCTION;
CodePush.sync({ deploymentKey });
  • Debug builds will use the Staging environment.
  • Release builds will use the Production environment.
    ‍

Step 4: Deploy Updates to the Correct Environment

Ensure that updates are released to the right deployment:

‍

Deploy to Staging

appsonair-codepush release-react MyApp-Staging --target-version 1.0.0

‍

Deploy to Production

appsonair-codepush release-react MyApp --target-version 1.0.0

‍

Why This Approach is Recommended

  • Prevents accidental releases – Test updates safely in a dedicated Staging environment.
  • Maintains clear separation – Staging and Production builds remain independent.
  • Scalability – Easily add additional environments like Beta or QA as needed.

By structuring your environments this way, you ensure a smooth update process and minimize risks when deploying changes.

Start managing your deployments efficiently with AppsOnAir CodePush today! 🚀

FAQ’s

No items found.

Actionable Insights,
Straight to Your Inbox

Subscribe to our newsletter to get useful tutorials , webinars,use cases, and step-by-step guides from industry experts

Start Pushing Real-Time App Updates Today
Try AppsOnAir for Free
Stay Uptodate