npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

rn-env-setup

v1.3.0

Published

CLI to automate Android product flavors, iOS schemes/xcconfig, and JS env generation for React Native multi-environment apps

Readme

rn-env-setup

Set up and manage multiple React Native environments (like dev, staging, prod) from one config file.

Install

npm install -g rn-env-setup
# or use without installing:
npx rn-env-setup init

Quick Start

cd your-react-native-app
npx rn-env-setup init
npx rn-env-setup validate
npx rn-env-setup generate

This creates native environment setup for Android + iOS and generates helpful scripts in your app package.json.

Minimal rn-env.yaml

appName: MyApp
packageName: com.myapp
jsEnvStrategy: react-native-config
generateJsEnv: true
generateCiSnippets: false
enableRollback: true

environments:
  - name: dev
    appName: MyApp Dev
    bundleId: com.myapp.dev
    apiUrl: https://dev.api.example.com
    variables:
      FEATURE_NEW_UI: true

  - name: staging
    appName: MyApp Staging
    bundleId: com.myapp.staging
    apiUrl: https://staging.api.example.com

  - name: prod
    appName: MyApp
    bundleId: com.myapp
    apiUrl: https://api.example.com

CLI Commands

  • rn-env-setup init: Interactive setup and creates rn-env.yaml
  • rn-env-setup validate: Validates config only
  • rn-env-setup generate: Applies Android + iOS + JS env generation
  • rn-env-setup generate --dry-run: Preview changes only
  • rn-env-setup generate --android-only: Skip iOS generation
  • rn-env-setup generate --ios-only: Skip Android generation
  • rn-env-setup generate --config path/to/rn-env.yaml: Use a custom config path
  • rn-env-setup rollback: Restores backed-up files

Common Scripts Generated In Your App

After generate, your app package.json gets scripts like:

  • env:android:run:dev
  • env:android:apk:dev:debug
  • env:android:apk:dev:release
  • env:android:aab:dev:release
  • env:ios:run:dev

(And equivalent scripts for each environment name.)

FAQ

1) How do I edit environments and regenerate?

  1. Update rn-env.yaml:
    • add/remove environments
    • change bundleId, apiUrl, variables, app names
  2. Run:
npx rn-env-setup validate
npx rn-env-setup generate

Use this first if you want to preview:

npx rn-env-setup generate --dry-run

2) How do I add Firebase google-services.json for each environment?

Use Android flavor-specific files:

  • android/app/src/dev/google-services.json
  • android/app/src/staging/google-services.json
  • android/app/src/prod/google-services.json

You can also keep a default fallback at:

  • android/app/google-services.json

Make sure your Android Firebase Gradle setup is already present in your RN app (com.google.gms.google-services plugin + classpath).

If you also use iOS Firebase, keep environment-specific GoogleService-Info.plist files and select/copy the right one per scheme/build step.

3) How do I run the app for an environment?

Use generated scripts:

npm run env:android:run:dev
npm run env:ios:run:dev

Replace dev with staging or prod.

4) How do I build APK, AAB, and IPA for different environments?

Android:

npm run env:android:apk:dev:debug
npm run env:android:apk:dev:release
npm run env:android:aab:dev:release

iOS archive (IPA flow):

cd ios
xcodebuild -workspace MyApp.xcworkspace -scheme MyApp-Dev -configuration Dev -archivePath build/MyApp-Dev.xcarchive archive

Then export IPA using your ExportOptions.plist:

xcodebuild -exportArchive -archivePath build/MyApp-Dev.xcarchive -exportPath build -exportOptionsPlist ExportOptions.plist

5) How do I use environment variables or base URL in code?

Each environment gets apiUrl and optional variables from rn-env.yaml.

If jsEnvStrategy: react-native-config:

import Config from 'react-native-config';

const baseUrl = Config.API_URL;
const featureFlag = Config.FEATURE_NEW_UI;

If jsEnvStrategy: custom, use generated src/env.ts:

import Config from './src/env';

const baseUrl = Config.API_URL;

6) How do I write test cases for different environments?

Use environment-specific test runs.

Jest example (API URL assertions):

const envs = ['dev', 'staging', 'prod'];

envs.forEach((env) => {
  test(`API URL exists for ${env}`, () => {
    process.env.ENV = env;
    // load env config and assert URL/flags
  });
});

Recommended strategy:

  • Unit tests: validate env config mapping and feature flags
  • Integration tests: mock API client per environment base URL
  • E2E tests: run per environment build/scheme in CI matrix

License

MIT