fflags
v2.0.1
Published
Feature flags npm package (browser and nodejs) with TypeScript support
Maintainers
Readme
Feature Flags
Installation
To use in browser
npm i fflagsyarn add fflagsTo use with node.js
npm i fflags node-fetch@2yarn add fflags node-fetch@2Usage
const { FeatureFlags } = require('fflags'); // Node.js CommonJS
import { FeatureFlags } from 'fflags'; // TypeScript ESModule
const SERVER_URL = 'https://yourserver.com';
const INSTANCE_NAME = 'instance-name';
const USER_EMAIL = '[email protected]';
const flagStorage = new FeatureFlags(`${SERVER_URL}/client/${INSTANCE_NAME}/${USER_EMAIL}`);
async function main() {
await flagsStorage.initialize(); // Fetch flags for specified instance and email
console.log(flagsStorage.checkFlag('flag-name')); // true/false
console.log(flagsStorage.flags); // [...]
}
main();