Effortless environment file synchronization
Did you receive the .env file I shared in Discord?
Never have out-of-date .env files for your projects or your team. envsync helps you syncing your .env
files using remote backends (Azure Storage, Azure Key Vault, Azure App Configuration) and eliminates the need to send .env
files via Discord, email or other channels. It provides a simple CLI to initialize, sync, update, check status, and clear environment files for your project.
Just initialize your .env files, update them at the remote if they change and let everyone who works with the project run envsync sync
to get the most recent changes.
- 🔍 Auto-detects
.env
files in your project (root and subfolders) - 🗂️ Supports multiple backends powered by unstorage: Currently supported Azure Storage, Azure Key Vault, Azure App Configuration
- Supports merging: Supports merging with existing settings in .env files. Duplicate keys will be overwritten by the remote state
- 📝 Interactive CLI for setup and management - Run
envsync --help
for available options
- Support for remote configuration/configurationless
- Support more storage providers
- Support remote encryption at rest
- Provide commandline switches to sync if out of date
- Initialize new envsync config with
envsync init
- Execute
envsync update
to push the configured.env
files to the remote location - Execute
envsync sync
anywhere you want to pull the current version from the remote location
- Add the optional dependencies of the backend you want to use to your devDependencies. For example for azure-storage, use
pnpm add -D @azure/identity @azure/storage-blob
- Execute
envsync sync
or in a configless setup (config file is also storage in the remote location)envsync sync --remote-config --backend-type azure-storage --azure-storage-accountName YOUR_ACCOUNT_NAME --azure-storage-containerName YOUR_CONTAINER_NAME
- The preferred way of authenticating to remote storage (for example Azure Key Vault) should be an interactive login session with
az login
orConnect-AzAccount
. Adding more env variables to authenticate to a service is not what we want to achieve. - Please cofigure permissions for reading and writing with your storage provider. For example in Azure you should only provide write permissions to people you want to update the .env files by assigning the respective RBAC (Role-Based Access Control) roles.
- We are not syncing comments due to how the merging and parsing works. If you need to have commented out lines synchronized, the only workaround it to not have a space between the
#
and the key
Is synced
#COMMENT_WITHOUT_SPACE=123
Is not synced
# COMMENT_WITH_SPACE=123
- Remember that secrets stored in
.env
files are unecrypted and should only be for local services or extremely temporary. They cannot be recalled once they are on someones computer.
pnpm add -D @visorian/envsync
or
pnpm add -g @visorian/envsync
pnpm exec @visorian/envsync <command> [options]
You can use envsync in a "configless" mode, where there is no envsync.json
save in your repo, but the config is also saved in the remote location.
To initialize a repo with a remote configuration, run
envsync init --remote-config --backend-type BACKEND_TYPE --azure-storage-accountName ACCOUNT_NAME --azure-storage-containerName CONTAINER_NAME
This will start the initialization wizard and automatically configures the backend with the provided parameters. There will be no envsync.json
config file be written to disk, but directly to your configured remote storage.
All other commands work like in a local configuration:
envsync update --remote-config --backend-type BACKEND_TYPE --azure-storage-accountName ACCOUNT_NAME --azure-storage-containerName CONTAINER_NAME
envsync sync --remote-config --backend-type BACKEND_TYPE --azure-storage-accountName ACCOUNT_NAME --azure-storage-containerName CONTAINER_NAME
envsync status --remote-config --backend-type BACKEND_TYPE --azure-storage-accountName ACCOUNT_NAME --azure-storage-containerName CONTAINER_NAME
All commands support a common set of options for backend selection, config file, directory, and backend-specific arguments. Run envsync <command> --help
for all options.
Interactively initialize a new environment sync configuration.
pnpm exec envsync init [options]
- Detects
.env
files in your project - Lets you select files and backend
- Stores config in
envsync.json
or remote
Synchronize local .env
files with the remote backend.
pnpm exec envsync sync [options]
- Downloads remote files if they differ from local
Update remote backend with your current local .env
files.
pnpm exec envsync update [options]
- Prompts before overwriting remote files
Show the status of your local .env
files compared to the remote backend.
pnpm exec envsync status [options]
- Tells you if files are up-to-date or out-of-date
Delete all synced .env
files from the remote backend.
pnpm exec envsync clear [options]
- Prompts for confirmation before deleting
Rescan for .env
files and update configuration.
pnpm exec envsync rescan [options]
- Updates the config with newly found
.env
files
Show the current configuration.
pnpm exec envsync config
Common options for all commands:
--directory, -d
Specify the directory to sync environment files--backend-type, -b
Specify the backend type (e.g., azure-storage, azure-key-vault, azure-app-config, local)--config-file, -c
Path to the envsync configuration file--overwrite, -o
Overwrite existing environment files in the remote location when running update--merge, -m
Merge with existing local environment files--remote-config, -r
Use configuration stored in remote location--includeSuffixes, -i
Include .env files with suffixes like .env.sample, .env.template- Azure backend-specific options (see above)
The configuration is stored in envsync.json
after running init
.
You can edit this file manually or re-run init
to update it.
Example:
{
"mergeEnvFiles": false,
"recursive": true,
"exclude": ["node_modules", ".git", "dist"],
"backend": {
"type": "azure-storage",
"name": "azure-storage",
"config": {
"accountName": "myaccount",
"containerName": "envfiles"
}
},
"files": [
{
"name": ".env",
"path": "/.env",
"extension": ""
},
{
"name": ".env.local",
"path": "/.env.local",
"extension": ".local"
}
]
}
- azure-storage: Uses Azure Blob Storage.
- azure-key-vault: Uses Azure Key Vault.
- azure-app-config: Uses Azure App Configuration.
You will be prompted for backend-specific options during init
.
MIT License © 2025 Jan-Henrik Damaschke (Github:@itpropro)