Flaggr is an OpenFeature-compatible feature flag management platform. It allows you to control features in your applications using the standard OpenFeature SDK.
npm install @openfeature/server-sdknpm install @openfeature/web-sdkimport { OpenFeature } from "@openfeature/server-sdk";
import { FlaggrProvider } from "./lib/provider";
// Initialize Flaggr provider
const provider = new FlaggrProvider({
apiUrl: "http://localhost:3000",
apiKey: "your-api-key" // optional
});
await OpenFeature.setProviderAndWait(provider);
// Get a client
const client = OpenFeature.getClient();
// Evaluate a boolean flag
const isEnabled = await client.getBooleanValue(
"new-feature",
false,
{ targetingKey: "user-123", email: "user@example.com" }
);
if (isEnabled) {
// Feature is enabled
console.log("New feature is enabled!");
}import { initializeFlaggr } from "./lib/client";
import { useBooleanFlag } from "./lib/client/react-hooks";
// Initialize in your app root (e.g., _app.tsx or layout.tsx)
await initializeFlaggr({
apiUrl: "http://localhost:3000",
});
// Use in your components
function MyComponent() {
const isNewFeatureEnabled = useBooleanFlag(
"new-feature",
false,
{ targetingKey: "user-123" }
);
return (
<div>
{isNewFeatureEnabled && (
<div>New Feature Content!</div>
)}
</div>
);
}// Response
{
"flags": [
{
"key": "new-feature",
"name": "New Feature",
"description": "Enable the new feature",
"type": "boolean",
"enabled": true,
"defaultValue": false,
"createdAt": "2025-01-01T00:00:00.000Z",
"updatedAt": "2025-01-01T00:00:00.000Z"
}
],
"total": 1
}// Request
{
"key": "new-feature",
"name": "New Feature",
"description": "Enable the new feature",
"type": "boolean",
"enabled": false,
"defaultValue": false
}// Request
{
"flagKey": "new-feature",
"context": {
"targetingKey": "user-123",
"email": "user@example.com"
},
"defaultValue": false
}
// Response
{
"flagKey": "new-feature",
"value": true,
"reason": "DEFAULT"
}true | false"production" | "staging"100 | 5000{ "theme": "dark" }