Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.
/ feature-toggles Public archive

A frontend feature toggling library for in-progress features

Notifications You must be signed in to change notification settings

jobilla/feature-toggles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jobilla Feature Toggles

This is a library for use in JavaScript and TypeScript applications to allow you to conditionally execute code/show some parts of your frontend depending on if a feature is enabled or not.

This is meant for in-development features where you might want to ship incrementally to your testing environment but ship the entire feature to your customers. It ensures that you can still deploy to production, but having unfinished features hidden.

Installation

This package can be installed with NPM:

npm install @jobilla/feature-toggles

Usage

First, to activate feature toggles for your app, simply instantiate the service:

const toggles = new FeatureToggleService();

You may then proceed to register any service you want:

toggles.register({
    name: "New Sidebar",
    key: "new_sidebar"
});

We recommend that you register all your features in the root of your application.

You may then, anywhere in your code, check whether the feature is enabled:

if (toggles.check('new_sidebar')) {
    renderNewSidebar();
} else {
    renderOldSidebar();
}

Enabling and disabling features

Features are stored as stringified JSON in localStorage. You may either manually change the enabled value for a feature in localStorage, or you can use our companion Chrome plugin.