{"id":51956552,"url":"https://github.com/dotenvx/react-native-dotenv","last_synced_at":"2026-07-29T11:30:29.622Z","repository":{"id":37783977,"uuid":"278097666","full_name":"dotenvx/react-native-dotenv","owner":"dotenvx","description":"Load react native environment variables using import statements for multiple env files.","archived":false,"fork":false,"pushed_at":"2026-07-28T18:00:11.000Z","size":1612,"stargazers_count":857,"open_issues_count":9,"forks_count":52,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-07-28T18:09:24.087Z","etag":null,"topics":["12factor","babel","babel-plugin","dotenv","environment-variables","hacktoberfest","react","react-native","react-native-config"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/react-native-dotenv","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dotenvx.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["goatandsheep"],"patreon":"goatandsheep","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":"goatandsheep","otechie":null,"custom":null}},"created_at":"2020-07-08T13:31:51.000Z","updated_at":"2026-07-28T18:00:41.000Z","dependencies_parsed_at":"2023-02-09T12:31:30.746Z","dependency_job_id":"4cd579b2-bc6e-475f-8547-5d800b530910","html_url":"https://github.com/dotenvx/react-native-dotenv","commit_stats":{"total_commits":322,"total_committers":21,"mean_commits":"15.333333333333334","dds":0.7701863354037267,"last_synced_commit":"7b57c0f2582f132c3513d38faa6e8a4fafe58370"},"previous_names":["dotenvx/react-native-dotenv"],"tags_count":51,"template":false,"template_full_name":null,"purl":"pkg:github/dotenvx/react-native-dotenv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotenvx%2Freact-native-dotenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotenvx%2Freact-native-dotenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotenvx%2Freact-native-dotenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotenvx%2Freact-native-dotenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dotenvx","download_url":"https://codeload.github.com/dotenvx/react-native-dotenv/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotenvx%2Freact-native-dotenv/sbom","scorecard":{"id":432811,"data":{"date":"2025-08-11","repo":{"name":"github.com/goatandsheep/react-native-dotenv","commit":"24b7af170ec299dc2605a6892167a65b5e162e6e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.6,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Security-Policy","score":4,"reason":"security policy file detected","details":["Info: security policy file detected: SECURITY.md:1","Warn: no linked content found","Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1","Info: Found text in security policy: SECURITY.md:1"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 1/13 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/dependabot.yml:1","Warn: no topLevel permission defined: .github/workflows/issuehunt.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/dependabot.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/goatandsheep/react-native-dotenv/dependabot.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/issuehunt.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/goatandsheep/react-native-dotenv/issuehunt.yml/main?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 26 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":5,"reason":"5 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T03:46:20.469Z","repository_id":37783977,"created_at":"2025-08-19T03:46:20.469Z","updated_at":"2025-08-19T03:46:20.469Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":36031401,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-29T02:00:04.910Z","response_time":95,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["12factor","babel","babel-plugin","dotenv","environment-variables","hacktoberfest","react","react-native","react-native-config"],"created_at":"2026-07-29T11:30:29.046Z","updated_at":"2026-07-29T11:30:29.617Z","avatar_url":"https://github.com/dotenvx.png","language":"JavaScript","funding_links":["https://github.com/sponsors/goatandsheep","https://patreon.com/goatandsheep","https://issuehunt.io/r/goatandsheep"],"categories":[],"sub_categories":[],"readme":"# react-native-dotenv [![NPM version](https://img.shields.io/npm/v/react-native-dotenv.svg?style=flat-square)](https://www.npmjs.com/package/react-native-dotenv) [![downloads](https://img.shields.io/npm/dw/react-native-dotenv)](https://www.npmjs.com/package/react-native-dotenv)\n\n\u003cimg src=\"https://raw.githubusercontent.com/motdotla/dotenv/master/dotenv.svg\" alt=\"dotenv\" align=\"right\" width=\"200\" /\u003e\n\nLoad `.env` into React Native with `import` statements. A Babel plugin that inlines your environment variables at build time — with multi-environment support.\n\n\u0026nbsp;\n\n## Usage\n\nInstall it.\n\n```sh\nnpm install react-native-dotenv --save-dev\n```\n\nAdd it to your Babel config:\n\n```js\n// babel.config.js\nmodule.exports = function (api) {\n  api.cache(false)\n  return {\n    plugins: [\n      ['module:react-native-dotenv']\n    ]\n  }\n}\n```\n\nCreate a `.env` file in the root of your project:\n\n```ini\n# .env\nHELLO=\"Dotenv\"\nAPI_URL=https://api.example.org\n```\n\nImport your environment variables:\n\n```js\n// App.js\nimport { HELLO, API_URL } from '@env'\n\nconsole.log(`Hello ${HELLO}`)\nfetch(`${API_URL}/users`)\n```\n\nThat's it. Your environment variables from `.env` are available via `@env`!\n\n```text\n◇ injected env (2) from .env\n```\n\n\u0026nbsp;\n\n## Advanced\n\n\u003cdetails\u003e\u003csummary\u003ewith Expo 🧭\u003c/summary\u003e\u003cbr\u003e\n\n```js\n// babel.config.js\nmodule.exports = function (api) {\n  api.cache(false)\n  return {\n    presets: ['babel-preset-expo'],\n    plugins: [\n      ['module:react-native-dotenv']\n    ]\n  }\n}\n```\n\n```ini\n# .env\nHELLO=\"Universe\"\n```\n\n```js\n// app/index.tsx\nimport { HELLO } from '@env'\nimport { Text } from 'react-native'\n\nexport default function HomeScreen() {\n  return \u003cText\u003eHello {HELLO}\u003c/Text\u003e\n}\n```\n\nThen start with a clean Metro cache: `npx expo start --clear`.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eenvName\u003c/code\u003e (default: \u003ccode\u003e'APP_ENV'\u003c/code\u003e)\u003c/summary\u003e\u003cbr\u003e\n\nOverride 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.\n\n```json\n// package.json\n{\n  \"scripts\": {\n    \"start:staging\": \"APP_ENV=staging npx react-native start\"\n  }\n}\n```\n\nThe above example would use the `.env.staging` file.\n\nTo use your own name:\n\n```json\n{\n  \"plugins\": [\n    [\"module:react-native-dotenv\", {\n      \"envName\": \"MY_ENV\"\n    }]\n  ]\n}\n```\n\n```json\n// package.json\n{\n  \"scripts\": {\n    \"start:staging\": \"MY_ENV=staging npx react-native start\"\n  }\n}\n```\n\nNote: 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](https://www.gatsbyjs.com/docs/how-to/local-development/environment-variables/#additional-environments-staging-test-etc). 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.\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003emoduleName\u003c/code\u003e (default: \u003ccode\u003e'@env'\u003c/code\u003e)\u003c/summary\u003e\u003cbr\u003e\n\nThe module name used in import statements.\n\n```js\nimport { HELLO } from '@env'\n```\n\nFor TypeScript or Next.js it is often advised to set `moduleName` to `react-native-dotenv`.\n\n```json\n{\n  \"plugins\": [\n    [\"module:react-native-dotenv\", {\n      \"moduleName\": \"react-native-dotenv\"\n    }]\n  ]\n}\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003epath\u003c/code\u003e (default: \u003ccode\u003e'.env'\u003c/code\u003e)\u003c/summary\u003e\u003cbr\u003e\n\nPath to the base env file.\n\n```json\n{\n  \"plugins\": [\n    [\"module:react-native-dotenv\", {\n      \"path\": \".env\"\n    }]\n  ]\n}\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eallowlist\u003c/code\u003e (default: \u003ccode\u003enull\u003c/code\u003e)\u003c/summary\u003e\u003cbr\u003e\n\nLimit imports to only these env variable names.\n\n```json\n{\n  \"plugins\": [\n    [\"module:react-native-dotenv\", {\n      \"allowlist\": [\n        \"HELLO\",\n        \"API_URL\"\n      ]\n    }]\n  ]\n}\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eblocklist\u003c/code\u003e (default: \u003ccode\u003enull\u003c/code\u003e)\u003c/summary\u003e\u003cbr\u003e\n\nPrevent these env variable names from being imported.\n\n```json\n{\n  \"plugins\": [\n    [\"module:react-native-dotenv\", {\n      \"blocklist\": [\n        \"GITHUB_TOKEN\"\n      ]\n    }]\n  ]\n}\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003esafe\u003c/code\u003e (default: \u003ccode\u003efalse\u003c/code\u003e)\u003c/summary\u003e\u003cbr\u003e\n\nOnly allow variables defined in your `.env` files. Host environment variables can still override values for those same keys at build time, but keys that exist only in the environment (and not in `.env`) are not imported.\n\n```json\n{\n  \"plugins\": [\n    [\"module:react-native-dotenv\", {\n      \"safe\": true\n    }]\n  ]\n}\n```\n\nWhen using safe mode, it's highly recommended to set `allowUndefined` to `false`.\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eallowUndefined\u003c/code\u003e (default: \u003ccode\u003etrue\u003c/code\u003e)\u003c/summary\u003e\u003cbr\u003e\n\nAllow importing undefined variables; their value will be `undefined`.\n\n```json\n{\n  \"plugins\": [\n    [\"module:react-native-dotenv\", {\n      \"allowUndefined\": true\n    }]\n  ]\n}\n```\n\n```js\nimport { UNDEFINED_VAR } from '@env'\n\nconsole.log(UNDEFINED_VAR === undefined) // true\n```\n\nWhen set to `false`, an error will be thrown.\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003everbose\u003c/code\u003e (default: \u003ccode\u003efalse\u003c/code\u003e)\u003c/summary\u003e\u003cbr\u003e\n\nAlso print the active dotenv mode to stderr while transforming.\n\n```json\n{\n  \"plugins\": [\n    [\"module:react-native-dotenv\", {\n      \"verbose\": true\n    }]\n  ]\n}\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003equiet\u003c/code\u003e (default: \u003ccode\u003efalse\u003c/code\u003e)\u003c/summary\u003e\u003cbr\u003e\n\nSuppress the stderr inject message (`◇ injected env (N) from .env`).\n\n```json\n{\n  \"plugins\": [\n    [\"module:react-native-dotenv\", {\n      \"quiet\": true\n    }]\n  ]\n}\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003eprocess.env\u003c/summary\u003e\u003cbr\u003e\n\nYou can also use `process.env` — the plugin inlines matching keys at build time the same way.\n\n```js\nconsole.log(`Hello ${process.env.HELLO}`)\nfetch(`${process.env.API_URL}/users`)\n```\n\n`process.env.X` is only inlined when `X` is in your `.env` files (plus `NODE_ENV` / `BABEL_ENV` / `envName`). That keeps build-tooling noise out of the bundle without special-casing tool names.\n\nFor host/CI-only values, use `@env` imports — or put the key in `.env` and let CI override the value.\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003eMulti-env\u003c/summary\u003e\u003cbr\u003e\n\nThis package now supports environment specific variables. This means you may now import environment variables from multiple files, i.e. `.env`, `.env.development`, `.env.production`, and `.env.test`. This is based on [dotenv-flow](https://www.npmjs.com/package/dotenv-flow).\n\nNote: it is not recommended that you commit any sensitive information in `.env` file to code in case your git repo is exposed. The best practice is to put a `.env.template` or `.env.development.template` that contains dummy values so other developers know what to configure. Then add your `.env` and `.env.development` to `.gitignore`. You can also keep sensitive keys in a separate `.env.local` (and respective `.env.local.template`) in `.gitignore` and you can use your other `.env` files for non-sensitive config.\n\nIf you are publishing your apps on an auto-publishing platform like EAS (Expo Application Services), make sure to put your secrets on the platform dashboard directly. If you are wondering what environment the platforms choose it is likely `.env.production` (not `.env.prod`) and there is likely no way to change this.\n\nThe base set of variables will be `.env` and the environment-specific variables will overwrite them.\n\nThe variables will automatically be pulled from the appropriate environment and `development` is the default. The choice of environment is based on your Babel environment first and if that value is not set, your NPM environment, which should actually be the same, but this makes it more robust.\n\nIn general, **Release** is `production` and **Debug** is `development`.\n\nTo choose, setup your scripts with `NODE_ENV` for each environment\n\n```json\n// package.json\n{\n  \"scripts\": {\n    \"start:development\": \"NODE_ENV=development npx react-native start\",\n    \"start:production\": \"NODE_ENV=production npx react-native start\"\n  }\n}\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003eTypes with Zod\u003c/summary\u003e\u003cbr\u003e\n\nPrefer [Zod](https://zod.dev) to validate your env and infer types — no hand-written `env.d.ts` needed.\n\n```ts\nimport { z } from 'zod'\n\nexport const env = z.object({\n  HELLO: z.string().min(1),\n  API_URL: z.string().url()\n}).parse({\n  HELLO: process.env.HELLO,\n  API_URL: process.env.API_URL\n})\n\nconsole.log(`Hello ${env.HELLO}`)\nfetch(`${env.API_URL}/users`)\n```\n\n`env` is fully typed from the schema. If a value is missing or invalid, Zod throws at startup instead of failing later in production.\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003eReference Material\u003c/summary\u003e\u003cbr\u003e\n\nIf you are not familiar with how dotenv or Babel work, make sure to read the following reference materials:\n\n* [babel environments](https://babeljs.io/docs/en/6.26.3/babelrc#env-option)\n* [dotenv documentation](https://www.npmjs.com/package/dotenv)\n* [See the wiki for more troubleshooting tips](https://github.com/goatandsheep/react-native-dotenv/wiki/Multi-env-troubleshooting)\n\n### How this works\n\nThis Babel plugin processes your `.env` files and your environment variables and replaces the references to the environment variables in your code before it runs. This is because the environment variables will no longer be accessible once the React Native engine generates the app outputs.\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003eCaching\u003c/summary\u003e\u003cbr\u003e\n\nWhen using with [`babel-loader`](https://github.com/babel/babel-loader) with caching enabled you will run into issues where environment changes won’t be picked up.\nThis is due to the fact that `babel-loader` computes a `cacheIdentifier` that does not take your `.env` file(s) into account. The good news is that a recent update has fixed this problem as long as you're using a new version of Babel. Many react native libraries have not updated their Babel version yet so to force the version, add in your `package.json`:\n\n```json\n\"resolutions\": {\n  \"@babel/core\": \"^7.20.2\",\n  \"babel-loader\": \"^8.3.0\"\n}\n```\n\nIf this does not work, you should set `api.cache(false)` in your babel config, which resets Babel cache.\n\nIf you're using android, add a clean task to your run command: `react-native run-android --tasks clean,installDebug`\n\nmetro.config.js`resetCache: true`\n\nYou can easily clear the cache:\n\n```shell\nrm -rf node_modules/.cache/babel-loader/*\n```\n\nor reset all caches\n\n`npm start -- --reset-cache`\n\nor\n\n`yarn start --reset-cache`\n\nor\n\n`yarn start --clear`\n\nor\n\n`jest --no-cache`\n\nor\n\n`expo r -c`\n\nand\n\n`expo start --clear`\n\nor\n\n`react-native clean`\n\nor\n\n`rm -rf .expo/web/cache`\n\nor\n\n[react-native-clean-project](https://www.npmjs.com/package/react-native-clean-project)\n\nMaybe a solution for updating package.json scripts:\n\n\u003e     \"cc\": \"rimraf node_modules/.cache/babel-loader/*,\",\n\u003e     \"android\": \"npm run cc \u0026\u0026 react-native run-android\",\n\u003e     \"ios\": \"npm run cc \u0026\u0026 react-native run-ios\",\n\nOr you can override the default `cacheIdentifier` to include some of your environment variables.\n\nThe tests that use `require('@env')` are also not passing.\n\nFor nextjs, you _must_ set `moduleName` to `react-native-dotenv`.\n\n\u003c/details\u003e\n\n\u0026nbsp;\n\n## FAQ\n\n\u003cdetails\u003e\u003csummary\u003eHow does this work?\u003c/summary\u003e\u003cbr/\u003e\n\nThis Babel plugin reads your `.env` files at build time and replaces `@env` imports (and matching `process.env` references) with their values before the React Native bundle is generated. Runtime Node `process.env` is not available in the app the same way.\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003eCan I put secrets in `.env`?\u003c/summary\u003e\u003cbr/\u003e\n\nNo. Values are inlined into your JavaScript bundle. Anyone who unpacks your app can read them. Only put public config in `.env` — keep real secrets on a server.\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003eCan I use this with Next.js?\u003c/summary\u003e\u003cbr/\u003e\n\nYes. Set `moduleName` to `react-native-dotenv` (Next.js already owns `@env`).\n\n```json\n{\n  \"plugins\": [\n    [\"module:react-native-dotenv\", {\n      \"moduleName\": \"react-native-dotenv\"\n    }]\n  ]\n}\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003eWhat about variable expansion?\u003c/summary\u003e\u003cbr/\u003e\n\nUse [dotenvx](https://github.com/dotenvx/dotenvx).\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003eShould I commit my `.env` file?\u003c/summary\u003e\u003cbr/\u003e\n\nNo.\n\nUnless you encrypt it with [dotenvx](https://github.com/dotenvx/dotenvx). Then we recommend you do.\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003eCan I use `process.env` instead?\u003c/summary\u003e\u003cbr/\u003e\n\nYes. The plugin inlines matching keys at build time the same way as `@env` imports.\n\n```js\nconsole.log(`Hello ${process.env.HELLO}`)\nfetch(`${process.env.API_URL}/users`)\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003eShould I have multiple `.env` files?\u003c/summary\u003e\u003cbr/\u003e\n\nWe recommend creating one `.env` file per environment. Use `.env` for local/development, `.env.production` for production and so on. This still follows the twelve factor principles as each is attributed individually to its own environment. Avoid custom set ups that work in inheritance somehow (`.env.production` inherits values from `.env` for example). It is better to duplicate values if necessary across each `.env.environment` file.\n\n\u003e In a twelve-factor app, env vars are granular controls, each fully orthogonal to other env vars. They are never grouped together as “environments”, but instead are independently managed for each deploy. This is a model that scales up smoothly as the app naturally expands into more deploys over its lifetime.\n\u003e\n\u003e – [The Twelve-Factor App](http://12factor.net/config)\n\nAdditionally, we recommend using [dotenvx](https://github.com/dotenvx/dotenvx) to encrypt and manage these.\n\nThis package also supports dotenv-flow-style files (`.env`, `.env.local`, `.env.\u003cmode\u003e`, `.env.\u003cmode\u003e.local`). See Multi-env under Advanced.\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003eWhat about syncing and securing `.env` files?\u003c/summary\u003e\u003cbr/\u003e\n\nUse [dotenvx](https://github.com/dotenvx/dotenvx) to unlock syncing encrypted `.env` files over git.\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003eWhy aren't my environment variables updating?\u003c/summary\u003e\u003cbr/\u003e\n\nUsually cache. Clear Metro/Babel cache and restart:\n\n```shell\nnpm start -- --reset-cache\n# or\nyarn start --reset-cache\n# or\nexpo start --clear\n```\n\nAlso set `api.cache(false)` in your Babel config (see Usage), or clear `node_modules/.cache/babel-loader/*`. See Caching under Advanced for more.\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003eWhat if I accidentally commit my `.env` file to code?\u003c/summary\u003e\u003cbr/\u003e\n\nRemove it, [remove git history](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository) and then install the [git pre-commit hook](https://github.com/dotenvx/dotenvx#pre-commit) to prevent this from ever happening again.\n\n```\nnpm i -g @dotenvx/dotenvx\ndotenvx precommit --install\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003eWhy can't I use `APP_ENV=development` or `production`?\u003c/summary\u003e\u003cbr/\u003e\n\nBabel/Node treat `development` and `production` specially. If you use `APP_ENV` (or `envName`), avoid those values — use something like `staging` / `release` instead. Prefer built-in `NODE_ENV=development` / `NODE_ENV=production` when you need those modes. See `envName` under Advanced.\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003eWhy is `import` from `@env` failing with module not found?\u003c/summary\u003e\u003cbr/\u003e\n\n`@env` is a virtual module created by this Babel plugin — it is not an npm package. Make sure `module:react-native-dotenv` is in your Babel config, restart Metro with a cache reset, and that your `moduleName` option matches the import (default `@env`).\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003eHow do I get TypeScript types for my environment variables?\u003c/summary\u003e\u003cbr/\u003e\n\nPrefer [Zod](https://zod.dev) to validate and infer types — see Types with Zod under Advanced.\n\n\u003c/details\u003e\n\u003cdetails\u003e\u003csummary\u003eWhat happens to environment variables that were already set?\u003c/summary\u003e\u003cbr/\u003e\n\nBy default, we will never modify any environment variables that have already been set. In particular, if there is a variable in your `.env` file which collides with one that already exists in your environment, then that variable will be skipped (the existing value wins at build time).\n\n`process.env.X` is only inlined when `X` appears in a `.env` file. Host/CI-only keys still work via `import { X } from '@env'`.\n\n\u003c/details\u003e\n\u0026nbsp;\n\n## CHANGELOG\n\nSee [CHANGELOG.md](CHANGELOG.md)\n\n\u0026nbsp;\n\n## Who's using react-native-dotenv?\n\n[These npm modules depend on it.](https://www.npmjs.com/browse/depended/react-native-dotenv)\n\nProjects that expand it often use the [keyword \"dotenv\" on npm](https://www.npmjs.com/search?q=keywords:dotenv).\n\n\u0026nbsp;\n\n## Credits\n\nLong maintained by [Kemal Ahmed](https://guidebolt.com) ([@goatandsheep](https://github.com/goatandsheep)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotenvx%2Freact-native-dotenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdotenvx%2Freact-native-dotenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotenvx%2Freact-native-dotenv/lists"}