@mathdoy/toggle-querystring

Toggle feature, a feature flag library for your frontend, enabled toggle through query string

Usage no npm install needed!

<script type="module">
  import mathdoyToggleQuerystring from 'https://cdn.skypack.dev/@mathdoy/toggle-querystring';
</script>

README

Toggle Query String

Toggle Restify library for toggle

Installation

$ npm install --save @mathdoy/toggle @mathdoy/toggle-querystring
import { createToggle } from "@mathdoy/toggle";
import { createToggleQuerystring } from "@mathdoy/toggle-querystring";

// ...

const toggleQuerystring = createToggleQuerystring({
  // Query string parameter
  param: "features",
  // Default features
  features: {
    logo: true,
  },
});

const toggle = createToggle({
  features: toggleQuerystring(window.location.search),
});

// toggleQuerystring("?features[foo]=1&features[bar]&features[qaz]=false")
// {
//     logo: true,
//     foo: true,
//     bar: true,
//     qaz: false
// }

// toggleQuerystring("?features[logo]=false")
// { logo: false } // default has been overriden

See a full example in toggle/blob/master/examples/react/src/index.js

For more information on toggle

For more information on toggle see toggle

Using it with react

$ npm install --save @mathdoy/toggle @mathdoy/toggle-querystring @mathdoy/toggle-react

See more information for toggle-react

License

Toggle is licensed under the MIT License.