npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@heroku/env-as-html-data

v1.0.2

Published

Inject environment variables into HTML pages as data-* attributes.

Maintainers

srishtigautamsrishtigautamaklimaiteaklimaitejsullivandigsjsullivandigsjulianduque-sfdcjulianduque-sfdccwallsfcwallsfijanakijanakjeffrey.estradajeffrey.estradadlira-sfdlira-sfntonollierntonollierdaebumleedaebumleetetsuya_tetsuya_mttrmttrelearyelearysalesforce-releasessalesforce-releasesanujpandey001anujpandey001sripad.kulkarnisripad.kulkarnikbaird-sfkbaird-sfcbaxtersfcbaxtersfryoneyamaryoneyamaadirasanamadirasanamnrisaronrisarocmarcojoscmarcojosmgates-salesforcemgates-salesforceademusoyoademusoyoelzoonaelzoonajondaniel-sfdcjondaniel-sfdcdhagberg-sfdhagberg-sfbencdentonbencdentonmarcelsfdcmarcelsfdcccaseyccaseyjoeybrown90sfjoeybrown90sfsuppadasuppadadiana.doherty.sfdcdiana.doherty.sfdchritchhritchryanbrainardryanbrainardrsoerensenrsoerensenjasoncummings-herokujasoncummings-herokubrock-salesforcebrock-salesforcetkoh-sfdctkoh-sfdcgnettergnettercoreypurcell_salesforcecoreypurcell_salesforceswapnilghoseswapnilghosestessema-sfcstessema-sfcjmonrealjmonrealbrittany.jonesbrittany.jonesrstiltonsfrstiltonsfnilamuthunilamuthusghaffarsghaffarcdwort-sfdccdwort-sfdcaaronromeosfdcaaronromeosfdckpremkumarkpremkumarrchandarchandaxx-sfdc-npmxx-sfdc-npmcv88cv88ekozilforceekozilforceumarsfdcumarsfdcbeanieboibeanieboindavidson-sfndavidson-sfmingzhi-liu1258mingzhi-liu1258angelcampbellangelcampbellmandeepsfmandeepsfyann_ckyann_ckdasofieidasofieisudarshanhiraysudarshanhirayalex_herokualex_herokusbosio_sfsbosio_sfsarahoh2468sarahoh2468tlowrimoretlowrimoreptemporiniptemporinitcareysmith-sfdctcareysmith-sfdcrobinson.mrobinson.mdkabanov1dkabanov1rdagg-herordagg-herok80bowmank80bowmansheax0rsheax0rdpark.herokudpark.herokudaniel.brightdaniel.brightjdowningjdowningabhinavkoulabhinavkouljoshwlewis-sfdcjoshwlewis-sfdcviniljainviniljaineblackeblackk.plentyk.plentyapadalaapadalalsorstokkelsorstokkercrossrcrosskdreyerorenkdreyerorendhammer25dhammer25tenharmsel_sftenharmsel_sfdougmcinnes-sfdcdougmcinnes-sfdcchap-herokuchap-herokumichellejhlimmichellejhlimmbuschherokumbuschherokubeckychenbeckychensmrutisamantasmrutisamantaapoorvasrivapoorvasrivhsophie-sfhsophie-sfp.shreyap.shreyasai_harshitha_neelasai_harshitha_neelanlanattanlanattadreichenbergdreichenbergvlazukavlazukamarsmarsheroku-front-endheroku-front-endrichatiwaririchatiwariwchrisjohnsonwchrisjohnsonthe7okathe7okasimonebonettisfitasimonebonettisfitalucaszhoulucaszhoupsalimpsalimtaylor.jonestaylor.jonesangelayoungangelayoungktsforcektsforcekerry-bennettkerry-bennettgkomminenigkomminenismukusmukudgallegossfdcdgallegossfdcrishabh.wasonrishabh.wasonsarassassinsarassassinarajaarajav.anandv.anandlmckenzielmckenziejordaneekeyjordaneekeydaigo-herokudaigo-herokumimenmimenjwadsworthsfjwadsworthsfpfuentepfuentebleongbleongpaguilarpaguilarzli-sfzli-sfsruthichsruthichjesse.brown-sfjesse.brown-sftij005tij005tholschuh-salesforcetholschuh-salesforcekumardinesh2kumardinesh2tholmes-sfdctholmes-sfdcpalakjeetkaur12palakjeetkaur12sfjonnpmsfjonnpmvjohnevjohnejinjutha.hancockjinjutha.hancockmgauger_herokumgauger_herokutdhayanandatdhayanandakharlowsfkharlowsfjhili!16jhili!16slizcoslizcoyasuhiro-herokuyasuhiro-herokuanna-crossanna-crosscromwellryan-sfcromwellryan-sfhyunwookleehyunwookleematthew.rossimatthew.rossitm-sftm-sfnkoziuknkoziukherokucodyherokucodydodom-sfdcdodom-sfdccsinghaus-sfdccsinghaus-sfdcjw-sfdcjw-sfdcjlopezdanjlopezdangsinghsfdcgsinghsfdcnrenkenrenkesalesforcegenesalesforcegenebsonntag-salesforcebsonntag-salesforcechetankd10chetankd10heroku-johnnyheroku-johnnyemilyhuang-herokuemilyhuang-herokumichael.malavemichael.malaveerika.wallaceerika.wallacevalluri056valluri056hk-ankitkumarhk-ankitkumarkaruna123karuna123mjoherson-sfmjoherson-sfskediyal-sfskediyal-sf

Readme

Inject Environment Variables as HTML Data Attributes

Supports runtime config var changes and pipeline promotions on Heroku

This module will inject the current environment variables as HTML data-* global attributes into the app's HTML files. These variables can be updated everytime the app starts. Rebuild of the javascript app is not required to pick-up Heroku config var changes.

Using this Module

  1. install to the Javascript project: npm install @heroku/env-as-html-data
  2. set web process start-up to occur after this module: npx env-as-html-data && bin/start-nginx-static

Configuration options (set as shell/environment variables):

  • ENV_AS_HTML_DATA_DIR (default public) the directory to search for HTML files to process.
  • ENV_AS_HTML_DATA_FILE_EXT (default .html) the file extension to match for files to process.

Using Runtime Environment Variables

Do not set secret values into these environment variables. They will be injected into the website, where anyone on the internet can see the values. As a precaution, only environment variables prefixed with PUBLIC_ prefix will be exposed.

The variable names are case-insensitive, accessed as lowercase. Although enviroment variables are colloquially uppercased, the resulting HTML Data Attributes are set & accessed lowercased, because they are case-insensitive XML names.

For example, if this app is started:

export PUBLIC_API_URL=https://localhost:3001
export PUBLIC_RELEASE_VERSION=v42
export PORT=3000
npm start

When the app is loaded in the web browser's javascript environment, these can be accessed using the HTML Data Attribtes:

const body = document.querySelector("body")

// These contain the env vars' values
body.dataset.public_api_url
body.dataset.public_release_version

// PORT is not set, because it isn't prefixed with PUBLIC_
body.dataset.port == null

Using Build-time Variables

Environment variables used to configure the build, such as Webpack configuration, should be accessed using the normal Node.js process.env object.

How does the runtime variable injection work?

When this module runs during app start-up, it:

  1. reads all PUBLIC_* environment variables
  2. updates each public/*.html file, writing these env vars as <body data-*> attributes
  3. serves the public/ directory as static files
  4. the body data attributes are available within javascript & CSS running in the pages.