@mathdoy/toggle-querystring
v1.1.0
Published
Toggle feature, a feature flag library for your frontend, enabled toggle through query string
Downloads
3
Maintainers
Readme
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.