react-remote-config

1.0.1 • Public • Published

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.

Package Sidebar

Install

npm i react-remote-config

Weekly Downloads

2

Version

1.0.1

License

GPL-3.0-or-later

Unpacked Size

37.3 kB

Total Files

4

Last publish

Collaborators

  • sergeykuzmich