flagout
v1.1.2
Published
Type-safe TypeScript SDK for Flagout Feature Flag as a Service
Maintainers
Readme
flag0ut TypeScript SDK
The official TypeScript SDK for flag0ut, a type-safe feature flag service.
Installation
Install the SDK using your favorite package manager:
npm install flagout
# or
yarn add flagout
# or
pnpm add flagoutUsage
Initialize the SDK with your API key:
import Flagout from 'flagout';
const flagout = new Flagout({
apiKey: 'YOUR_API_KEY',
});Then, you can evaluate a feature flag using the evaluate method:
const { showFeature } = await flagout.evaluate('my-feature-flag');
if (showFeature) {
// Show the feature
}You can also specify a user role and ID to evaluate the flag for a specific user:
const { showFeature } = await flagout.evaluate('my-feature-flag', 'BETA', 'user-123');API Reference
new Flagout(config)
Creates a new Flagout instance.
config(TSDKConfig): The SDK configuration.apiKey(string): Your Flagout API key.
flagout.evaluate(slug, userRole?, userId?)
Evaluates a feature flag.
slug(string): The slug of the feature flag to evaluate.userRole(TRoles): The role of the user to evaluate the flag for. Defaults to'ALL'.- Possible values:
'ALL','BETA','INTERNAL','PREMIUM'.
- Possible values:
userId(string): The ID of the user to evaluate the flag for.
Returns a promise that resolves to an object with the following properties:
showFeature(boolean): Whether to show the feature.message(string): A message from the server.
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
License
This project is licensed under the ISC License.
