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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@socheatsok78/webenv

v0.6.0

Published

Loads variables from .env for web projects.

Downloads

244

Readme

@socheatsok78/webenv

Loads variables from .env for web projects.

npm-downloads license

Story

What is Dotenv?

Dotenv is a zero-dependency module that loads environment variables from a .env file into process.env. Storing configuration in the environment separate from code is based on The Twelve-Factor App methodology.

Why Webenv?

While dotenv provide a convenient way of loading environment variables from a .env file for Node.js, however managing runtime environment variables for the web doesn't seem to be any easier.

This project is aimed to fix the those on the web by providing a wrapper to dotenv using fetch to make a request for .env file from your publicly accessible path. It is a highly customized dotenv and dotenv-expand built for the web.

Install

npm install @socheatsok78/webenv --save

Or installing with yarn?

yarn add @socheatsok78/webenv

Usage

Create a .env file in the public folder of your project:

# Please DO NOT store your sensitive data here
# This file must be publicly accessible by anyone
API_BACKEND_ENDPOINT="https://api.example.com"

NOTE:

The webenv do not have access to the server environment variables. You can consider that the webenv is only use for runtime configuration only.

As early as possible in your application, import and configure dotenv:

import * as webenv from '@socheatsok78/webenv'

(async () => {
    await webenv.config({ path: '/.env' }) // make a fetch request to '/.env' and parse the string response
    console.log(window.env) // remove this after you've confirmed it working
})()