React Native Dotenv screenshot

React Native Dotenv

Author Avatar Theme by Goatandsheep
Updated: 28 Feb 2024
854 Stars

Load react native environment variables using import statements for multiple env files.

Categories

Overview:

The react-native-dotenv package allows developers to inject environment variables into their JavaScript environment using dotenv for multiple environments. It is designed for use with React Native and is compatible with various platforms, including web applications.

Features:

  • Import Technique: Ability to use import statements to manage environment variables.
  • Safe Mode: Enable safe mode to restrict usage to variables defined in the .env file.
  • Allow and Block Lists: Control which environment variables are imported using allowlist and blocklist.
  • Override envName: Define a custom environment name to manage different environments effectively.

Installation:

To install this package, follow these steps:

Using Yarn:

yarn add react-native-dotenv

Breaking Changes:

When moving from v0.x to v2.x, there are significant changes in setup and usage. It is recommended to refer to the migration guide.

Summary:

The react-native-dotenv package simplifies the management of environment variables in React Native applications. By allowing the import of variables, enabling safe mode, and providing options for controlling variable scope, developers can efficiently handle environment configurations. With the ability to override environment names, this package offers flexibility for managing multiple environments seamlessly.