Skip to content

Instantly share code, notes, and snippets.

@ApolloTang
Last active July 18, 2018 03:12
Show Gist options
  • Save ApolloTang/8bab754d56b629f7763168e61cc55f04 to your computer and use it in GitHub Desktop.
Save ApolloTang/8bab754d56b629f7763168e61cc55f04 to your computer and use it in GitHub Desktop.

react-native-dotenv

link

Read environment vairable from .env file

Usage :

filename: .env

  API_KEY=lorem
  ANOTHER_CONFIG=foobar

use it directly in RN js code:

  import { API_KEY, ANOTHER_CONFIG } from 'react-native-dotenv'
  ApiClient.init(API_KEY, ANOTHER_CONFIG)

reference


babel-plugin-transform-inline-environment-variables

link

Pass Bash variable to RN js code

reference reference


Related to Buddy build

reference


react-native-config

link

Same as react-native-dotenv but require to write code in Object-C and Java


react-native-env

link

No good: ios only need to configure setting in Xcode

mention a good reference: migrating-ios-app-through-multiple-environments

reference


#To read:

Automated environment management in React Native - iOS

The 12 factor app


[ref 1] Setting environment variable in react-native?

[ref 2] react-native-run-ios-loading-environment-variables

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment