Dynamic variables based on environment (or anything else!)
feats' dynamic-variables is a minimalist choice for switching environmental variables in your app.
[ Getting started 🤓 | Check it on NPM 👌 ]
Setting up
Installing it
You can install it from one of these 3 options:
with NPM
$ npm install dynamic-variables
with Yarn
$ yarn add dynamic-variables
manually
you may also install it as a development dependency in a package.json file:
// package.json "dependencies":
Then install it with either npm install
or yarn install
Getting started
Basic usage
// it will be assigned 'API_SERVER_PUBLIC` in the browser and 'API_SERVER_CONTAINER' in the serverconst backendEndpoint =
Advanced usage
Multiple named environments + Custom environment detector
// it will be assigned 'API_SERVER_PUBLIC` in the browser and 'API_SERVER_CONTAINER' in the serverconst backendEndpoint =
Multiple services endpoints
moduleexports =
For more examples, please check the tests file.
I hope you enjoy using this tiny lib! 🎉
This project is sponsored by feats.
Join a community of people helping each other get credit for their roles in projects.
From developing products and apps to architecture and campaigns.