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 🙏

© 2025 – Pkg Stats / Ryan Hefner

dotenv-sync

v0.0.5

Published

This library is a layer on top of [dotenv](https://www.npmjs.com/package/dotenv), that lets you safely and easily share .env files with your team.

Readme

dotenv-sync

This library is a layer on top of dotenv, that lets you safely and easily share .env files with your team.

It works by encrypting all of your secret ENV vars using a private key, that can then be stored in 1Password, or LastPass etc.

Set up a project

  • npm install dotenv-sync to install it
  • $(npm bin)/dotenv-sync --init to initialise the project

Change your existing code from:

import dotenv from "dotenv";
dotenv.config();

to

import dotenv from "dotenv-sync";
dotenv.config();

What to commit

DO commit:

  • .env-encrypted — this file is what keeps your team in sync. It's securely encrypted, and safe to commit publicly

Do NOT commit:

  • .env-unencrypted.env — this file contains all of your secret keys. If you commit this, you might as well not use this library at all and just commit your .env directly.

A sample .gitignore you might want to use is as follows:

# .gitignore
*.env
!.env-encrypted

Custom error messaging

When new teammates attempt to run your codebase, if they haven't created a .env-unencrypted.env file, then they will hit an error.

If you want to customise this error message, so your teammates know where to get the file from, you can create a .dotenv-sync.missing-secret-key message in your workspace.

For example:

echo "Check the shared 1Password, in the item titled 'space jam website'" > .dotenv-sync.missing-secret-key

Bundle size

In production-mode, dotenv-sync defers entirely to dotenv, making it effectively zero in additional bundle size.

Security

Is this package secure?

This library encrypts your ENV vars using 256-bit AES.

For reference, this is the same encryption that 1Password uses. In other words, using this package is cryptographically as secure as storing all of your ENV vars directly in a 1Password vault.

Why not just commit the ENV vars to source?

If your repo is public, then this is obviously a bad idea, as anyone can e.g. log into your database.

If your repo is private, then this is still a bad idea. All it takes is one person to get hacked, and suddenly the hacker has access to all of your databases. By using this package, even if someone hacks their way to your source-code, they won't be able to decrypt your ENV vars.

Update ENV vars

To update ENV vars locally just for you, then you should just add to your .env file.

To update ENV vars for your team, you can:

  • modify the .env-unencrypted.env file
  • run $(npm bin)/dotenv-sync to update the .env-encrypted file
  • commit the new .env-encrypted file, and push this to source control

Using ENV vars

Priority

Anything in your .env takes top priority, and will override anything else.

For example, in:

# .env
TEST=hello

# .env-unencrypted.env
TEST=goodbye

then process.env.TEST === 'hello'

Environment groups

The .env-unencrypted.env offers groups, as an optional feature. You can specify an active group with the _ENV_GROUP_TARGET environment variable.

For example, in:

# .env
_ENV_GROUP_TARGET=Local

# .env-unencrypted.env
#~~~ Local
TEST=hello

#~~~ Development
TEST=goodbye

then process.env.TEST === 'hello'