Skip to content

jrgf/remotevars

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

14 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

๐ŸŒ RemoteVars

RemoteVars is a modern Node.js library and CLI tool that lets you manage environment variables from remote sources โ€” like GitHub, HTTP endpoints, or local JSON files โ€” eliminating the need for .env files in your projects.


๐Ÿš€ Features

  • ๐Ÿ”’ Load configuration securely from:
    • GitHub repositories (private or public)
    • HTTP(S) endpoints
    • Local JSON files
  • ๐Ÿง  Optional local cache for offline resilience
  • โš™๏ธ CLI tool for pulling, printing, and loading variables
  • ๐Ÿ’ป Works with Node.js, Express, React, or any framework
  • โ˜๏ธ Perfect for distributed teams and CI/CD setups

๐Ÿ“ฆ Installation

npm install -g remotevars

or for local development:

npm install remotevars --save-dev

๐Ÿงฎ Usage

1๏ธโƒฃ Basic CLI Usage

Pull environment variables and save them to .env.local:

npx remotevars pull --provider=github --repo=myorg/configs --path=envs/dev.json

Load variables directly into process.env (in-memory):

npx remotevars load --provider=http --url=https://example.com/config.json

Print variables to console (for debugging):

npx remotevars print --provider=local --path=./envs/dev.json

Clear local cache:

npx remotevars clear-cache

2๏ธโƒฃ .remotevars.json Configuration File

Create a .remotevars.json in your project root to define your preferred provider(s):

{
  "defaultProvider": "github",
  "useCache": true,
  "github": {
    "repo": "myorg/myconfigs",
    "path": "envs/dev.json",
    "branch": "main",
    "token": "ghp_XXXXXXX"
  },
  "http": {
    "url": "https://example.com/config.json"
  },
  "local": {
    "path": "./envs/dev.json"
  }
}

โšก Disabling Cache

You can disable the caching system globally or per command.

Option 1: In the .remotevars.json

{
  "useCache": false
}

Option 2: CLI flag

npx remotevars pull --no-cache

When cache is disabled, RemoteVars always fetches fresh data from the provider and never stores or reads from the cache.


๐Ÿง™โ€โ™‚๏ธ Supported Providers

Provider Description Required Options
github Fetch from a GitHub repository repo, path, optional branch, token
http Fetch from any HTTP/HTTPS endpoint returning JSON url
local Load from a local JSON file path
s3 Fetch from a GitHub repository bucket, key, optional region, token

๐Ÿงฑ Programmatic Usage (Node.js API)

You can also use RemoteVars directly in your code:

import { loadRemoteVars } from "remotevars";

await loadRemoteVars({
  provider: "github",
  repo: "myorg/myconfigs",
  path: "envs/dev.json",
  token: process.env.GH_TOKEN,
  useCache: false
});

console.log(process.env.API_KEY);

๐Ÿฅช Testing

Run unit tests:

npm test

๐Ÿ—บ๏ธ Roadmap

  • ๐Ÿ” Add encrypted secrets support
  • โ˜๏ธ Add AWS S3 and GCP provider support
  • ๐Ÿงฉ Add .remotevarsrc global configuration

๐Ÿง‘โ€๐Ÿ’ป Author

Created by Jose R. Garcia
๐Ÿ“ฆ GitHub: @jrgf


๐Ÿชช License

MIT License โ€” feel free to use, modify, and distribute.


RemoteVars โ€” Your environment, remotely controlled.

About

A simple lib to remotely fetch env vars

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors