@lds/universal-env

Safe, universal environment variables in 3 easy steps

Stats

StarsIssuesVersionUpdatedCreatedSize
@lds/universal-env
1.0.33 years ago4 years agoMinified + gzip package size for @lds/universal-env in KB

Readme

Universal Environment Variables

Safe, universal environment variables in 3 easy steps 😬.

1. Define what to share

Do this early in the application's lifecycle.

import { share } from "@lds/universal-env";

share("NODE_ENV", "GRAPHQL_ENDPOINT");

2. Populate a script tag in the document template

Add as script tag when generating the document. The script function returns a string of javascript.

import { script } from "@lds/universal-env";
<script>{script()}</script>

3. Access shared variables.

import { get } from "@lds/universal-env";

const { NODE_ENV, GRAPHQL_ENDPOINT } = get();

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.