react-native-dotenv weekly downloads statistics
By dotenvx · npm · Babel plugins
Load .env into React Native with import statements. A Babel plugin that inlines environment variables at build time.
react-native-dotenv has 438,011 recorded weekly downloads on npm, an increase of 15.5% over the past 30 days, ranking #414 of 3,247 tracked listings.
About react-native-dotenv
react-native-dotenv

<img src="https://raw.githubusercontent.com/motdotla/dotenv/master/dotenv.svg" alt="dotenv" align="right" width="200" />
Load .env into React Native with import statements. A Babel plugin that inlines your environment variables at build time — with multi-environment support.
Usage
Install it.
npm install react-native-dotenv --save-dev
Add it to your Babel config:
// babel.config.js
module.exports = function (api) {
api.cache(false)
return {
plugins: [
['module:react-native-dotenv']
]
}
}
Create a .env file in the root of your project:
# .env
HELLO="Dotenv"
API_URL=https://api.example.org
Import your environment variables:
// App.js
import { HELLO, API_URL } from '@env'
console.log(`Hello ${HELLO}`)
fetch(`${API_URL}/users`)
That's it. Your environment variables from .env are available via @env!
◇ injected env (2) from .env
Advanced
<details><summary>with the dotenv CLI</summary><br>Use dotenv v18's dotenv run command when you want the same environment variables available to build tooling and your app's @env imports. The Babel plugin still inlines values into the app at build time.
Install dotenv directly so your package manager makes its CLI available to your project scripts:
npm install --save-dev dotenv@^18.0.1
Select a file when starting Metro:
{
"scripts": {
"start:staging": "dotenv run -f .env.staging -- react-native start --reset-cache"
}
}
# .env.staging
API_URL=https://staging.example.org
Keep the Babel plugin configured as shown in Usage, then import normally:
import { API_URL } from '@env'
fetch(`${API_URL}/users`)
The CLI loads the selected file into the process environment before Metro starts. Existing shell/CI values win unless you pass --override to dotenv run. The plugin then gives non-empty process environment values priority over its own .env files.
The plugin still loads its usual files; -f selects the CLI's file, not the plugin's path or APP_ENV. This can change precedence: plain dotenv run loads .env into the process environment, so those values win over the plugin's .env.local values. Use the CLI when you intend its injected values to take priority.
With the default safe: false, keys loaded only by the CLI work through @env imports. With safe: true, those keys must also appear in files the plugin reads. Likewise, process.env.X is only inlined for keys in the plugin's files (plus NODE_ENV, BABEL_ENV, and envName).
Stop Metro and rerun the script after changing CLI-loaded values; its process environment is set at startup. The script resets Metro's cache when restarting.
The CLI is optional. For values used only by app code, the Babel plugin can continue loading .env files on its own.
// babel.config.js
module.exports = function (api) {
api.cache(false)
return {
presets: ['babel-preset-expo'],
plugins: [
['module:react-native-dotenv']
]
}
}
# .env
HELLO="Universe"
// app/index.tsx
import { HELLO } from '@env'
import { Text } from 'react-native'
export default function HomeScreen() {
return <Text>Hello {HELLO}</Text>
}
Then start with a clean Metro cache: npx expo start --clear.
Override which environment variable selects the mode file (separate from NODE_ENV). Metro can overwrite the test environment even if you specify a config, so this gives you a dedicated override.
// package.json
{
"scripts": {
"start:staging": "APP_ENV=staging npx react-native start"
}
}
The above example would use the .env.staging file.
To use your own name:
{
"plugins": [
["module:react-native-dotenv", {
"envName": "MY_ENV"
}]
]
}
// package.json
{
"scripts": {
"start:staging": "MY_ENV=staging npx react-native start"
}
}
Note: if you're using APP_ENV (or envName), you cannot use development nor production as values, and you should avoid having a .env.development or .env.production. This is a Babel and Node thing that I have little control over unfortunately and is consistent with many other platforms that have an override option, like Gatsby. If you want to use development and production, you should not use APP_ENV (or envName), but rather the built-in NODE_ENV=development or NODE_ENV=production or you can just use debug vs release modes. It actually does compile but only for the start command so it is up to you but then you have to run react-native start every time you change the values.
The module name used in import statements.
import { HELLO } from '@env'
For TypeScript or Next.js it is often advised to set moduleName to react-native-dotenv.
{
"plugins": [
["module:react-native-dotenv", {
"moduleName": "react-native-dotenv"
}]
]
}
</details>
<details><summary><code>path</code> (default: <code>'.env'</code>)</summary><br>
Path to the base env file.
{
"plugins": [
["module:react-native-dotenv", {
"path": ".env"
}]
]
}
</details>
<details><summary><code>allowlist</code> (default: <code>null</code>)</summary><br>
Limit imports to only these env variable names.…
Description from the npm listing.
- dotenv
- babel-plugin
- babel
- dotenv-flow
- react
- react-native
- config
- env
- 12factor
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (592)Similar npm Babel plugins plugins
All 20 react-native-dotenv alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/react-native-dotenv. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.