Sitemap
Ashok Polu

Ashok Polu

Member-only story

Build Configuration Scripts for React Native

4 min readJun 8, 2025
Press enter or click to view image in full size
Photo by La-Rel Easter on Unsplash

Not a member? click here

As a React native developer at one time, you need to support multiple environments like ALPHA, BETA, and PROD for your application. So each .env has different configurations like Server base URL, Secret keys, etc..

Usually, developers maintain constant keys in the application for each environment and comment out not required keys while at build and running the application.

const BASE_URL="https://www.alpha.com/v1"
//const BASE_URL="https://www.beta.com/v1"
//const BASE_URL="https://www.prod.com/v1"
const SECRET_KEY="<<alpha-key>>"
//const SECRET_KEY="<<beta-key>>"
//const SECRET_KEY="<<prod-key>>"

This works fine when you work on a small-scale application and less configuration, think about large-scale applications that have a huge configuration, and by mistake, you miss out on any one of the keys related to a specific environment not uncommented which would cause big trouble.

Step 1

Maintain different configuration files (.env) for different environments

Alpha -> .env.alpha

ENV_NAME=Alpha
API_URL=https://alpha-api.com/v1/
FIREBASE_KEY=asd32432sd-ek49595-smdker40505smdk
...

Beta -> .env.beta

ENV_NAME=Beta…

--

--