Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @mars/heroku-js-runtime-env with all npm packages installed. Try it out:

var herokuJsRuntimeEnv = require("@mars/heroku-js-runtime-env")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@mars/heroku-js-runtime-env v3.0.2

Runtime env var support for static javascript apps on Heroku

Heroku JS Runtime Env

Use runtime environment variables in bundled/minified javascript apps.

Build Status npm Module

Usage

Designed for create-react-app-buildpack. See its documentation to use this module for Runtime configuration.

Background

Normally javascript apps are compiled into a bundle before being deployed. During this build phase, environment variables may be embedded in the javascript bundle, such as with Webpack DefinePlugin.

When hosting on a 12-factor platform like Heroku, these embedded values may go stale when setting new config vars or promoting through a pipeline.

How Does It Work?

When developing your app, use Runtime environment variables from create-react-app-buildpack.

Then, each time the app starts-up on Heroku, a .profile.d script (installed from the buildpack) is executed which fills in a JSON placeholder in the JavaScript bundle with the runtime environment variables. The result is 🍃fresh runtime environment variables in the production javascript bundle without recompiling.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free