Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-config

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-config - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

ios/ReactNativeConfig/Dotenv.xcconfig

2

package.json
{
"name": "react-native-config",
"version": "0.0.2",
"version": "0.0.3",
"description": "Expose config variables to React Native apps",

@@ -5,0 +5,0 @@ "keywords": ["env", "config", "config-var", "react-native", "android", "ios", "12factor"],

@@ -14,3 +14,3 @@ # Config variables for React Native apps

API_URL=https://myapi.com
LOG_ERRORS=true
GOOGLE_MAPS_API_KEY=abcdefgh
```

@@ -23,7 +23,56 @@

Config.API_URL // 'https://myapi.com'
Config.SHOW_ERRORS // 'true'
Config.API_URL // 'https://myapi.com'
Config.GOOGLE_MAPS_API_KEY // 'abcdefgh'
```
### Android
Config variables set in `.env` are available to your Java classes via `BuildConfig`:
```java
public HttpURLConnection getApiClient() {
URL url = new URL(BuildConfig.API_URL);
// ...
}
```
You can also read them from your Gradle configuration:
```groovy
signingConfigs {
release {
storeFile file(project.env.get("RELEASE_STORE_FILE"))
storePassword project.env.get("RELEASE_STORE_PASSWORD")
keyAlias project.env.get("RELEASE_KEY_ALIAS")
keyPassword project.env.get("RELEASE_KEY_PASSWORD")
}
}
```
And use them to configure libraries in `AndroidManifest.xml` and others:
```xml
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/GOOGLE_MAPS_API_KEY" />
```
### iOS
Xcode support is missing; variables declared in `.env`. can be consumed from React Native apps in iOS via `Config`, but not from `plist` files.
### Different environments
Save config for different environments in different files: `.env.staging`, `.env.production`, etc.
By default react-native-config will read from `.env`, but you can change it setting `ENVFILE` before running it, like:
```
$ ENVFILE=.env.staging react-native run-android
```
This is only support in Android at the moment – The iOS equivalent should be coming soon.
## Setup

@@ -30,0 +79,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc