Manage Dynamic Environments in React Native: Simplifying Build Generation Process

May 14, 2024

Manage Dynamic Environments in React Native: Simplifying Build Generation Process

This article breaks down the GeekSpeak talk on managing dynamic environments in React Native applications, presented by Raghav Walia, Senior Software Engineer III at GeekyAnts.

Author

Ahona Das
Ahona DasSenior Technical Content Writer

Managing dynamic environments in a React Native application is essential for optimizing the build generation process and ensuring smooth deployment across various regions. This talk delves into the best practices and tools to handle this effectively, particularly focusing on environment variables and automation.


Understanding Environment Variables

Environment variables are crucial for storing global values, such as API endpoints, that need to be accessed throughout the app. However, it is essential to avoid storing sensitive information in these variables as they can be easily decoded from the source code. Careful consideration must be given to what is stored in these environment files.


Tools for Managing Environment Variables

In React Native, tools like react-native-config are used to handle environment variables. For web applications, .env files are commonly utilized. These tools enable the storage and retrieval of environment-specific variables, facilitating smoother builds and deployments.


Project Overview: Multi-Region Support

Building a React Native application that supports multiple regions

Our current project is a React Native application that supports multiple regions. From a single codebase, we generate two distinct apps, each catering to different regions. This results in four separate builds: two for Android and two for iOS. Managing these builds manually is time-consuming and prone to errors, making automation a necessity.


Handling App Configurations

Handling app configurations

To manage separate app configurations from a single codebase, especially for Android, we utilize product flavors and flavor dimensions. This approach allows us to differentiate apps based on UI elements like icons and logos. By specifying product flavors in the build.gradle file, we can create distinct builds for different environments (development, staging, production).

Using react-native-config, we inject environment variables into the build process, ensuring each app version uses the correct configurations.


Automation with App Center

Automating the build generation process with tools like App Center significantly reduces manual effort. App Center is a comprehensive CI/CD tool that supports cross-platform builds, environment variable management, crash reporting, analytics, and over-the-air updates. It integrates seamlessly with development tools like Bitbucket pipelines, triggering builds automatically based on code changes.

Benefits of App Center

  1. Reduction in Build Generation Time: Automating builds eliminates the need for manual intervention, speeding up the process.
  2. Consistency and Reliability: Automated builds reduce the potential for human errors, ensuring consistent and reliable outputs.
  3. Enhanced Security: Centralized management of environment variables enhances security by minimizing exposure to sensitive information.
  4. Scalability and Flexibility: The ability to manage multiple branches and environment variables allows for easy scalability and flexibility.
  5. Speedy Delivery of Testing Builds: Quick and efficient delivery of testing builds to QA teams ensures timely feedback and iterations.


Synchronizing Backend and Frontend Deployments

Synchronised backend and frontend deployments

A significant challenge in our project was synchronizing backend and mobile deployments. Since the app review process by Google and Apple takes time, the app needs to be fully functional during this period. We tackled this by dynamically managing environment variables using AWS Secrets Manager.


AWS Secrets Manager Integration

By storing dynamic environment variables, such as API endpoints, in AWS Secrets Manager, we ensure that the app can seamlessly switch between QA and production environments without the need for additional builds. This approach allows the backend to be deployed first, followed by the frontend, ensuring that both are in sync and the app remains functional during the review process.


Deployment Strategy

Deployment strategy
  1. Merge Backend Changes to QA Branch: This ensures stability and prepares the backend for deployment.
  2. Create Mobile Build from Main Branch: The frontend code is prepared for production.
  3. Submit Build for Review: The app is submitted for review with the backend still pointing to the QA environment.
  4. Merge Backend Changes to Main: Once the build is approved, the backend is deployed to production.
  5. Dynamic Environment Handling: Using AWS Secrets Manager, the app fetches production environment variables without requiring a new build.
Hire Us Form


Summing Up

Managing dynamic environments in a React Native application involves a combination of tools and strategies to ensure efficient build generation and deployment. By leveraging App Center for automation and AWS Secrets Manager for dynamic environment variables, we achieved a streamlined and secure deployment process, minimizing errors and enhancing productivity.

Donโ€™t miss out on the entire talk and presentation here โฌ‡๏ธ

Subscribe to Our Newsletter

More from the engineering frontline.

Dive deep into our research and insights on design, development, and the impact of various trends to businesses.
Insight
Why Legacy Systems Make Business Growth More Expensive: Navigate A Smarter Path to Legacy Modernization
Sep 23, 2026

Why Legacy Systems Make Business Growth More Expensive: Navigate A Smarter Path to Legacy Modernization

Learn how legacy systems make business growth more expensive and how edge-first modernization can remove constraints without replacing the existing system.

Insight
SSO, Audit Logs and RBAC: The Enterprise Features AI Prototyping Tools Do Not Cover | Sarika Gautam
Sep 23, 2026

SSO, Audit Logs and RBAC: The Enterprise Features AI Prototyping Tools Do Not Cover | Sarika Gautam

Why AI-generated prototypes fail enterprise review: the context behind SSO, the cost of skipping audit logs, and how role explosion makes RBAC a product of its own.

Insight
Feature Flags as Technical Debt: The Cleanup Nobody Schedules
Sep 21, 2026

Feature Flags as Technical Debt: The Cleanup Nobody Schedules

This blog explains how unmanaged feature flags create technical debt and how teams can detect, manage, and remove them safely.

Insight
Building AI-First Enterprises: Why System Design Matters More Than AI Adoption
Sep 21, 2026

Building AI-First Enterprises: Why System Design Matters More Than AI Adoption

This blog explores how system design, architecture, and validation shape AI-first enterprises, while examining AIโ€™s impact on software engineering and human decision-making.

Insight
The Product Studio in the AI Era: What Actually Changes | Sarika Gautam
Sep 21, 2026

The Product Studio in the AI Era: What Actually Changes | Sarika Gautam

What changes in product development when AI writes the code: the shift to architecture, the token cost of unplanned builds, and why juniors still matter.

Insight
AI and the Future of Digital Customer Experience: Where Technology Meets Human Creativity
Sep 18, 2026

AI and the Future of Digital Customer Experience: Where Technology Meets Human Creativity

A discussion on how AI, human creativity, research, and cross-functional collaboration are shaping the future of digital customer experience.

Insight
Scaling Down Before Scaling Up: Why Bigger Servers Donโ€™t Fix Bad Architecture
Sep 17, 2026

Scaling Down Before Scaling Up: Why Bigger Servers Donโ€™t Fix Bad Architecture

This blog explores how inefficient backend architecture can cause performance issues even under low traffic, covering practical ways to reduce database load, API latency, and resource usage before scaling infrastructure.

Footer

The Right Conversation Can

Save You Six Months.

Book a Call