@lds/universal-env

1.0.3 • Public • Published

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();

/@lds/universal-env/

    Package Sidebar

    Install

    npm i @lds/universal-env

    Weekly Downloads

    7

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    4.06 kB

    Total Files

    4

    Last publish

    Collaborators

    • blakeplumb
    • eatrocks
    • jnielson94
    • ldschurch
    • trevordmiller