Links
Comment on page

Feature Flags in JavaScript

Installation

Simply embed our latest bundle from the following CDN.
<script src="https://cdn.jsdelivr.net/npm/@ops-ai/[email protected]/dist/feature-flags-toggly.bundle.js"></script>
Alternatively, you can use NPM to manually build the bundled *.js file.
$ npm install @ops-ai/feature-flags-toggly
$ cd node_modules/@ops-ai/feature-flags-toggly && npm run build
And then grab the generated bundled file from the ./dist directory.

Basic Usage

Initialize Toggly by running the Toggly.init method and by providing your App Key from your Toggly application page
Toggly.init({
appKey: '<YOUR_APP_KEY>',
environment: '<YOUR_APP_ENVIRONMENT>'
})
.then(function () {
// Now you can check if a feature (or more) is Enabled/Disabled
if (Toggly.isFeatureOn('SignUpButton')) {
// SignUpButton is ON
}
if (Toggly.isFeatureOff('DemoScreenshot')) {
// DemoScreenshot is OFF
}
});
You can also check multiple feature keys and make use of the requirement (FeatureRequirement.all, FeatureRequirement.any) and negate (bool) options.