Skip to content

Load npm & environment variables from .env to react native

Notifications You must be signed in to change notification settings

egislook/react-native-expand-dotenv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-expand-dotenv

Loads npm & environment variables from a .env to react native

Installation

$ npm install --save-dev react-native-expand-dotenv

Usage

package.json / .babelrc

{
  "presets": [
    "module:metro-react-native-babel-preset",
    "module:react-native-expand-dotenv"
  ]
}

if its monorepo please add ["module:react-native-expand-dotenv", { "dirname": "your_monorepo_package_directory_name"}]

.env

NAME=$npm_package_name
VERSION=$npm_package_version
DOMAIN=https://example.domain

In index.js

import env, { NAME, VERSION, DOMAIN} from 'react-native-expand-dotenv'
process.env = { ...process.env, ...env }

console.log(process.env, { NAME, VERSION, DOMAIN })

Inspiration

react-native-dotenv

About

Load npm & environment variables from .env to react native

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published