react-native-config /react-native-config
Bring some 12 factor love to your mobile apps!
★ 4,951⑂ 656👁 28⑃ 330● 594▤ 37
+0
Daily
4,951
stars
656
forks
28
watchers
330
prs
594
issues
37
releases
README
react-native-config Config variables for React Native apps, supporting iOS, Android, macOS and Windows. Expose config variables to your JavaScript code — bring some 12 factor love to your mobile apps! [!TIP] Help keep this library maintained. If react-native-config is useful to you or your company, please consider sponsoring it on Open Collective. Contributions go toward the maintenance work that keeps it working across new React Native releases. See Sponsors for the tiers and what sponsorship pays for. Basic Usage Create a new file .env in the root of your React Native app: API_URL=https://myapi.com GOOGLE_MAPS_API_KEY=abcdefgh Then access variables defined there from your app: js import Config from "react-native-config"; Config.API_URL; // 'https://myapi.com' Config.GOOGLE_MAPS_API_KEY; // 'abcdefgh' Keep in mind this module doesn't obfuscate or encrypt secrets for packaging, so do not store sensitive keys in .env. It's basically impossible to prevent users from reverse engineering mobile app secrets, so design your app (and APIs) with that in mind. Setup ✅ The latest version of react-native-config is tested with React Native 0.87 (New Architecture) — see the example app. On Windows it is tested with react-native-windows 0.79, the newest React Native version react-native-windows supports today — see the Windows example app. ⚠️ Note (Android): react-native-config v1.6.0+ requires React Native 0.74 or higher. If you use an older RN version, see Troubleshooting below. Install the package: $ yarn add react-native-config Link the library: On React Native 0.60 and above there is no link step — the library is autolinked. Rebuild the app so the native side is picked up. On iOS / macOS, install the pod first: (cd ios; pod install) [!WARNING] Do not link this library manually on React Native 0.60 or above, and do not disable its autolinking in react-native.config.js. Autolinking is what registers the native module and, on the New Architecture, generates its TurboModule bindings — adding include ':react-native-config' to android/settings.gradle instead does neither, and the module then resolves to null at runtime. See TypeError: Cannot read property 'getConfig' of null. (Note: For Windows, this module supports autolinking when used with [email protected] or later. For earlier versions you need to manually link the module.) Manual linking — only for React Native below 0.60, or react-native-windows below 0.63 $ react-native link react-native-config (react-native link was removed from the React Native CLI; it is only available on the older versions these instructions apply to.) - Manual Link (iOS / macOS) 1. In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name] 2. Go to node_modules ➜ react-native-config ➜ ios and add ReactNativeConfig.xcodeproj 3. Expand the ReactNativeConfig.xcodeproj ➜ Products folder 4. In the project navigator, select
Top issues
#330Task :react-native-config:verifyReleaseResources FAILED51 comments · 2019-02-06#413iOS Integration change - clarification39 comments · 2019-11-23#444React Native 0.62.1 [iOS] - Empty config file in JS32 comments · 2020-04-05#125Can't Find GeneratedDotEnv.m Upon Build30 comments · 2017-06-02#514cocoapods script phases25 comments · 2020-10-26#156Configuration of bundle id in Info.plist not working25 comments · 2017-09-12#683Build input file cannot be found with Xcode 1424 comments · 2022-09-19#652Environment Variables keeps reading from .env20 comments · 2022-03-30
Latest release
v1.7.2 v1.7.2 2026-08-28Documentation add funding metadata and a sponsor tier section by @luancurti in https://github.com/react-native-config/react-native-config/pull/891 Chores ios: accumulate dotenv values without copying the hash by @OskarEichler New Contributors @OskarEichler made their first contribution in https://github.com/react-native-config/react-native-config/pull/891 Full Changelog: https://github.com/react-native-config/react-native-config/compare/v1.7.1...v1.7.2