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

react-native-config

Package Overview
Dependencies
Maintainers
4
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-config

Expose config variables to React Native apps

  • 1.4.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
253K
increased by4.37%
Maintainers
4
Weekly downloads
 
Created

What is react-native-config?

The react-native-config package allows you to manage and use environment variables in your React Native application. It helps you to keep sensitive information like API keys, server URLs, and other configuration settings out of your codebase, making your app more secure and easier to manage.

What are react-native-config's main functionalities?

Loading Environment Variables

This feature allows you to load environment variables from a .env file into your React Native application. You can access these variables using the Config object.

import Config from 'react-native-config';

const apiUrl = Config.API_URL;
console.log('API URL:', apiUrl);

Different Environments

You can define different environment variables for different environments (e.g., development, production) and use them to conditionally execute code based on the current environment.

import Config from 'react-native-config';

const environment = Config.ENV;
if (environment === 'production') {
  // Production-specific code
} else {
  // Development-specific code
}

Using Environment Variables in Native Code

// Android (build.gradle)
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"

// iOS (AppDelegate.m)
#import "ReactNativeConfig.h"
NSString *apiUrl = [ReactNativeConfig envFor:@
0

Keywords

FAQs

Package last updated on 10 Oct 2022

Did you know?

Socket

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.

Install

Related posts

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