Learn how to integrate feature flags into your Node.js applications and services
The core package of MyFlags SDK, providing the fundamental functionality for feature flag management in any JavaScript environment.
npm install @myflags/core
Initialize the SDK with your configuration:
import { MyFlagsSDK } from "@myflags/core";
// Initialize the SDK with your configuration
const sdk = new MyFlagsSDK({
apiKey: "your-api-key",
projectId: "your-project-id",
environment: "production", // optional, defaults to 'production'
refreshInterval: 600000, // optional, defaults to 10 minutes
});
Use the SDK to check feature flags:
// Get all feature flags
const flags = await sdk.getFlags();
// Check if a specific feature is enabled
const isEnabled = await sdk.getFlag("feature_key");
Subscribe to flag updates to get real-time notifications when flags change:
const sdk = new MyFlagsSDK({
apiKey: "your-api-key",
projectId: "your-project-id",
refreshInterval: 5000, // Check for updates every 5 seconds
});
// Subscribe to flag updates
const unsubscribe = await sdk.subscribe((flags) => {
console.log("Flags updated:", flags);
});
// Later, when you want to stop receiving updates
unsubscribe();
Full TypeScript support with type-safe flag names and values.
Manage different flag states across development, staging, and production environments.
Optimized for performance with caching and efficient updates.
Subscribe to flag changes and get real-time updates.