react-remote-config
v1.0.1
Published
Get configuration depending on environment (domain) application runned on.
Downloads
16
Maintainers
Readme
React Remote Config
The package allows to use environment configuration for static prebuilt react applications.
📦 Installation
NPM
npm i react-remote-config
Yarn
yarn add react-remote-config
🍽 Usage
Import configuration loader in your src/index.js
file:
import configLoader from 'react-remote-config';
then replace
ReactDOM.render(<Application />, document.getElementById('root'));
with
configLoader(dsn)
.then(() => {
ReactDOM.render(<Application />, document.getElementById('root'));
})
.catch(() => {
ReactDOM.render(<div>Couldn't get application configuration. Please, try to refresh the page.</div>, document.getElementById('root'));
});
The package will download json formatted configuration located under
dsn
URI. (defaults to/environment.json
)
Use window.env.{param}
to get configuration value in any application's file.
🧨 Warning
The package currently do not work with SSR frameworks such as NextJS, Gatsby, etc.