Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including @polkadot/ui-settings with all npm packages installed. Try it out:

require("@polkadot/networks/package.json"); // @polkadot/networks is a peer dependency. require("@polkadot/util/package.json"); // @polkadot/util is a peer dependency. var uiSettings = require("@polkadot/ui-settings")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@polkadot/ui-settings v0.62.1

Manages app settings

@polkadot/ui-settings

Manages app settings including endpoints, themes and prefixes

Usage Examples

User preferences are set as a settings object in the browser's local storage.

import settings from '@polkadot/ui-settings';

render () {
  // get api endpoint for the selected chain
  const WS_URL = settings.apiUrl();

  // get the selected il8n language
  const language = settings.il8nLang();

  // get all available il8n languages
  const languages = settings.availableLanguages();

  // update settings
  const updatedSettings = {
    ...settings,
    i18nLang: 'Arabic'
  }
  settings.set(updatedSettings);

  // NOTE: API currently does not handle hot reconnecting properly,
  so you need to manually reload the page after updating settings.
  window.location.reload();
}

Used by

Apps that currently use the settings package

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free