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.