Setup Multiple Environments in React Native | Development & Production

preview_player
Показать описание
Hey devs, in this video, I’ll show you how to set up multiple environments for a React Native app, including development and production. Learn how to add different .env files for each environment
- Library repo (react-native-config):
- Commands:

If this helped you out, a little coffee goes a long way ☕😊

Video sections:
00:00 - Intro
00:35 - Setup
00:56 - Android extra step
01:47 - iOS extra steps
07:10 - .env files
07:52 - Using env variables
08:56 - Running the iOS app
10:30 - Running the Android app
11:43 - Outro
Рекомендации по теме
Комментарии
Автор

Wow, this is by far the best video of how to set RN environments. Thank you. Saved my day 🙏

plujudramunqk
Автор

I was following the doc for IOS but didn't work for me, this saved me. Thanks a lot men 💪

johnanoni
Автор

Thank you very much. Very much detailed (y)

MagedMegz
Автор

Thank you so much !!! 🙏
This is working for me

my package.json script is like this

{
"setDevelopmentEnvFile": "ENVFILE=.env.development",
"setStagingEnvFile": "ENVFILE=.env.staging",
"setQAEnvFile": "ENVFILE=.env.qa",
"setProductionEnvFile": "ENVFILE=.env.production",
"android": "react-native run-android",
"ios": "react-native run-ios",
"lint": "eslint .",
"start": "react-native start",
"test": "jest",
"start:dev": "yarn setDevelopmentEnvFile react-native start",
"start:qa": "yarn setQAEnvFile react-native start",
"start:prod": "yarn setProductionEnvFile react-native start",
"start:stage": "yarn setStagingEnvFile react-native start"
}

everlastingstudios
Автор

I understood perfectly my friend, thank you, I have a small question, sorry for bothering you. I'm still a newbie in react native! I already have the different .env... now how could I use that for, for example, the manual process that I currently have... I have it resolved in local now I automatically use the .env.local... but normally what I do in production is a cd to the android folder then a gradle clean, then I change the version of the app (versionName and versionCode) to the one that corresponds and then a gradle bundlerelease and with that I generate the abb and upload it to google play console... it was intended Use your environment method so that when doing something similar to: npm run release-prod-bundle the gradle clean and the gradle bundlerelease are done using the production .env, would you know how to do it? thanks in advance.

RubenSemprun-dd
Автор

then put command line yarn run android-local . I get error 'ENVFILE' is not recognized as an internal or external command . Where is ENVFILE . I do not see on this video

Trietnk
Автор

what about if i want to run the app from the xcode run button, how will it choose the right env file?

yogendra
Автор

because there is no such command written by you in your package.json script???

MoGulzar-wy
Автор

I'm getting this error: 'ENVFILE' is not recognized as an internal or external command,
operable program or batch file.

hassamshamas
Автор

how we will set environment while releasing bundle?

DaniyalBaig-srbs
Автор

how to export the app with different env

fz
Автор

how to set different packagename on ios

imam_robani
Автор

how can we build the app to share the apk to someone?

like $ cd android
For APK: ./gradlew assembleRelease
For AAB (Play Store): ./gradlew bundleRelease

answer Please

MoGulzar-wy
visit shbcf.ru