Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react native environment variables

# .env files
API_URL=https://myapi.com
GOOGLE_MAPS_API_KEY=abcdefgh

# use env
import Config from 'react-native-config'

Config.API_URL  // 'https://myapi.com'
Config.GOOGLE_MAPS_API_KEY  // 'abcdefgh'

# call env
development: ENVFILE=.env.staging react-native run-android
production: cd android && ENVFILE=.env.production ./gradlew assembleRelease
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #react #native #environment #variables
ADD COMMENT
Topic
Name
8+8 =