@rapido/env

Modules to manage environment variables in Rapido apps.

Usage no npm install needed!

<script type="module">
  import rapidoEnv from 'https://cdn.skypack.dev/@rapido/env';
</script>

README

@rapido/env

This package includes modules to manage environment variables in Rapido apps.

Please refer to the Rapido documentation:

Installation

yarn add @rapido/env

Getting Started

// First initialize the env (e.g. during build process)
import initEnv from '@rapido/env/init';

// First initialize
initEnv({ NODE_ENV: 'development' });
// Later in code you can access env vars after the package has been initialized
import getEnv from '@rapido/env';

console.log(getEnv('NODE_ENV'));

API

initEnv(envars: { [key: string]: string }): void

Accepts an object of environment values and stores them for later.

import initEnv from '@rapido/env/init';

initEnv({ NODE_ENV: 'development' });

getEnv(key: string): string

Accepts a key string and returns the env variable value for that key.

import getEnv from '@rapido/env';

console.log(getEnv('NODE_ENV'));