@sizzle/remote-config

Remote configuration that is either fetched or cached locally for your React Native app or PWA

Usage no npm install needed!

<script type="module">
  import sizzleRemoteConfig from 'https://cdn.skypack.dev/@sizzle/remote-config';
</script>

README

remote-config

Remote configuration that is either fetched or cached locally for your React Native app or PWA

Config is used as a browser/embedded utility to provide auto refreshing remote configuration with local persistance and caching.

Persistance is disabled by default. To enable it - provide it in the constructor.

Example of usage

const path = 'https://raw.githubusercontent.com/sizzlehq/remote-config/master/package.json';
const headers = { 
  'Authorization': 'Bearer 9145221F-F8F9-4A5C-8487-1EBA74386877'
};

const defaultConfig = {
  key: 'value'
};

(async (): Promise<void> => {
  let config;

  try {
    config = new Config(defaultConfig, path, {
      storage: localStorage,
      headers: headers
    });
    await config.fetch();
  } catch (err) {
    throw new Error(`couldn't fetch config - ${err}`);
  }

  config.autoRefresh();
  const repType = config.value('repository.type'); // "git"
});