tenit-features
v1.0.1
Published
Typescript/Javascript client library for interacting with the Tenit Features tool managing feature flags.
Downloads
3
Readme
Tenit Features JS/TS Client
Typescript/Javascript client library for interacting with the Tenit Features tool managing feature flags.
Installation
# Yarn
yarn add tenit-features
# NPM
npm install tenit-features
Usage
Early in your app's lifecycle you'll want to initialize the library with the init()
function and include the api token you've created (Find your API tokens here). For most, this will be in the App.ts
/App.js
file of your project.
import * as Feature from "tenit-features";
Feature.init("your-api-token");
import * as Feature from "tenit-features";
// Checking if the feature is enabled for user abc-123
const isMyFeatureEnabled : Boolean = await Features.isEnabled("my-feature", "abc-123");
Note: If you're using react, we recommend managing the state of the flags in a useState
value and fetching it using a useEffect
like this:
import * as Feature from "tenit-features";
const [isMyFeatureEnabled, setIsMyFeatureEnabled] = useState(false);
useEffect(() => {
Feature.isEnabled("newUi", "abc-123").then(setIsMyFeatureEnabled);
}, []);
Tenit Features
Not yet using Tenit Features to manage feature flags in your apps? Learn more about it here.