Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

react-remote-config

sergeykuzmich38GPL-3.0-or-later1.0.1

Get configuration depending on environment (domain) application runned on.

react, config, environemnt, remote-config, environment-config

readme

React Remote Config

npm npm npm bundle size Snyk Vulnerabilities for npm package NPM

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.