
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@bitscheme/react-native-dotenv
Advanced tools
A Babel preset let you `import` application configs from **.env** file (zero runtime dependency)
Let you import environment variables from a .env file in React Native, don't need any native code integration.
$ npm install react-native-dotenv --save-dev
Add the react-native-dotenv preset to your .babelrc file at the project root.
{
"presets": ["react-native", "react-native-dotenv"]
}
If you haven't got .babelrc set up for React Native, remember to install babel-preset-react-native first.
$ npm install babel-preset-react-native --save-dev
Add your app configuration in an .env file.
API_KEY=lorem
ANOTHER_CONFIG=foobar
Now you can import it in your .js file.
import { API_KEY, ANOTHER_CONFIG } from 'react-native-dotenv'
ApiClient.init(API_KEY, ANOTHER_CONFIG)
As you can see, it's implemented as a babel plugin. All referenced imported members are replaced as the values specified in the .env file.
The example above will get compiled as below.
ApiClient.init('lorem', 'foobar')
Manually edit the file importing react-native-dotenv by either adding an empty line or whitespace will work.
Yes, simply create a separate .env.production file and the default release process of react-native will pickup the right config.
You can use the Release configuration to launch the Simulator. (Only supported in RN v0.39+)
react-native run-ios --configuration Release
Command⌘ + M to launch the developer menu in Android emulator.production & development environment configs?Sadly, it's not available so far. One of the workaround is generating .env file before triggering RN's bundle script automatically using either shell script or your own custom build pipeline.
MIT License, see LICENSE file for detail.
FAQs
A Babel preset let you `import` application configs from **.env** file (zero runtime dependency)
We found that @bitscheme/react-native-dotenv demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.