Socket
Socket
Sign inDemoInstall

rn-dotenv

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rn-dotenv - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

.circleci/config.yml

2

package.json
{
"name": "rn-dotenv",
"version": "0.2.0",
"version": "0.2.1",
"description": "A Babel preset let you `import` application configs from **.env** file (zero runtime dependency)",

@@ -5,0 +5,0 @@ "main": "index.js",

# rn-dotenv
Let you `import` environment variables from a **.env** file in React Native, **don't** need any native code integration.
# NOTE: [npm babel-plugin-dotenv-import](https://github.com/tusbar/babel-plugin-dotenv-import) is the new rewrite location
[![CircleCI](https://circleci.com/gh/zetachang/rn-dotenv.svg?style=svg)](https://circleci.com/gh/zetachang/rn-dotenv)
Let you `import` environment variables from a **.env** file in React Native, **don't** need any native code integration. This is the maintained fork of the abandoned repository.
[![CircleCI](https://circleci.com/gh/goatandsheep/rn-dotenv.svg?style=svg)](https://circleci.com/gh/goatandsheep/rn-dotenv)
[![npm version](https://img.shields.io/npm/v/rn-dotenv.svg?style=flat-square)](https://www.npmjs.com/package/rn-dotenv)

@@ -29,2 +31,10 @@ [![npm downloads](https://img.shields.io/npm/dt/rn-dotenv.svg?style=flat-square)](https://www.npmjs.com/package/rn-dotenv)

You may have to reset cache before this works:
```sh
$ npm start -- --reset-cache
$ yarn start --reset-cache
$ npx react-native start --reset-cache
```
## Usage

@@ -47,2 +57,23 @@

### Typescript
If you're using this in a Typescript react native project, Typescript will complain that the named import does not exist in the package.
Here's a solution to solve the problem.
Steps
1. Create a file `env.d.ts` (The filename doesn't matter, as long it ends with `.d.ts`)
2. In the file write the following (for this example, I'll use `API_KEY` as the environment variable)
```ts
declare module 'react-native-dotenv' {
/**
* API key
*/
export const API_KEY: string;
}
```
3. Now import the enviornment variable and your good to go. Ex: ` import { API_KEY } from 'react-native-dotenv'`
Solution provided by https://github.com/zetachang/react-native-dotenv/issues/76#issuecomment-585171009
## How does it work?

@@ -86,6 +117,9 @@

### How do I use this with Continuous Integration?
When using a CI tool you will have to write the environment variables to the `.env` file. In Github Actions you may for example add a line like `echo -e "${{ secrets.DOTENV }}" > .env`.
## Contact
[David Chang](http://github.com/zetachang)
[@zetachang](https://twitter.com/zetachang)
[Kemal Ahmed](http://github.com/goatandsheep)

@@ -92,0 +126,0 @@ ## LICENSE

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