@webiny/feature-flags
TypeScript icon, indicating that this package has built-in type declarations

5.39.6 • Public • Published

@webiny/feature-flags

code style: prettier PRs Welcome

A small library that provides a simple way to define and read feature flags in a Webiny project.

Table of Contents

Installation

npm install --save @webiny/feature-flags

Or if you prefer yarn:

yarn add @webiny/feature-flags

Overview

The @webiny/feature-flags exports a single featureFlags object which contains all of the feature flags initially set via the Webiny project's webiny.project.ts config file, via its featureFlags property.

For example, given the following webiny.project.ts config file;

// webiny.project.ts
export default {
    name: "webiny-js",
    cli: {
        ...
    },
    
    // Feature flags are defined via a simple JavaScript object.
    featureFlags: {
        myCustomFeatureFlag: false,
        someFeature: { enabled: true, myCustomProperty: 123, thisIsJson: "yes"}
    }
};

Within both backend and frontend application code, the featureFlags object can then be read like so:

import { featureFlags } from "@webiny/feature-flags"; 

const useMyCustomFeature = featureFlags.myCustomFeatureFlag;

const someOtherFeatureMyCustomProperty = featureFlags.someFeature.myCustomProperty;

NOTE

Behind the scenes, it's the Webiny CLI that enables the propagation of the featureFlags object into the actual applications. As mentioned, the featureFlags object can be accessed within both backend and frontend application code.

Examples

No additional examples.

Reference

Objects

featureFlags

Type Declaration

declare let featureFlags: Record<string, any>;

The featureFlags object contains all of the feature flags initially set via the Webiny project's webiny.project.ts config file, via its featureFlags property.

import { featureFlags } from "@webiny/feature-flags";

const useMyCustomFeature = featureFlags.myCustomFeatureFlag;

const someOtherFeatureMyCustomProperty = featureFlags.someFeature.myCustomProperty;

Readme

Keywords

none

Package Sidebar

Install

npm i @webiny/feature-flags

Weekly Downloads

329

Version

5.39.6

License

MIT

Unpacked Size

6.83 kB

Total Files

6

Last publish

Collaborators

  • webiny