Forge Feature Flags is now available as part of Forge Early Access Program (EAP). To start testing this feature, sign up using this form.
Forge Feature Flags is an experimental feature offered to selected users for testing and feedback purposes. This feature is unsupported and subject to change without notice. Do not use Forge Feature Flags in apps that handle sensitive information and customer data. The Feature flags EAP is fully functional in development, staging, and production environments.
Note: Feature flags are not available in Atlassian Government Cloud or FedRAMP environments. See, Limitations.
The Feature flags SDK in Forge is the in-code tool that developers use to flag their features. The SDK runs in Forge functions (resolvers, triggers, and other backend code) and provides local evaluation of feature flags.
The server-side SDK (@forge/feature-flags-node) is designed for Forge runtime and Forge resolvers.
Key characteristics:
Install the server SDK using npm:
1 2npm install @forge/feature-flags-node@latest
The SDK follows a simple pattern:
After initialization, the SDK evaluates flags without a network request, typically in less than 1ms.
The user object is the input you provide to the SDK for flag targeting. If you want to target on an attribute, you need to add it to your user object.
The interface for the User Object is:
1 2interface FeatureFlagUser { custom?: Record<string, string | number>; attributes?: { installContext?: string; accountId?: string; appVersion?: string; license?: string; capabilitySet?: string; }; identifiers?: { installContext?: string; accountId?: string; }; }
identifiers: Dictionary containing key/value pairs for feature flag targeting, especially for percentage-based rollouts. Supports installContext and accountId.
attributes: Dictionary containing key/value pairs for feature flag targeting. Supports:
installContextappVersionlicensecapabilitySetcustom: Dictionary for custom targeting attributes not supported in the attributes field.
A user object with identifiers is required for checkFlag. Always pass the accountId or installContext if available to ensure a stable experience.
1 2import { getAppContext } from "@forge/api"; import { ForgeFeatureFlags } from "@forge/feature-flags-node"; export const handler = async (payload, context) => { // Get app context values const { appVersion, license: appLicense, environmentType, } = getAppContext(); // Determine license value based on trialEndDate and isActive let licenseValue = "INACTIVE"; const trialEndDate = appLicense?.trialEndDate; const isActive = appLicense?.isActive; if (trialEndDate) { const now = new Date(); const trialEnd = new Date(trialEndDate); if (trialEnd > now) { licenseValue = "TRIAL"; } else if (isActive) { licenseValue = "ACTIVE"; } } else if (isActive) { licenseValue = "ACTIVE"; } // Determine capabilitySet value (enum) let capabilitySetValue = "capabilityStandard"; if (appLicense?.capabilitySet === "capabilityAdvanced") { capabilitySetValue = "capabilityAdvanced"; } // Initialize the feature flags SDK const featureFlags = new ForgeFeatureFlags(); await featureFlags.initialize({ environment: environmentType?.toLowerCase() || "development" }); // Define a user with all possible attributes for feature flag rules const user = { identifiers: { accountId: context?.principal?.accountId, }, attributes: { installContext: context?.installContext, accountId: context?.principal?.accountId, appVersion: appVersion, license: licenseValue, // "ACTIVE", "INACTIVE", "TRIAL" capabilitySet: capabilitySetValue // "capabilityAdvanced", "capabilityStandard" } }; // Check a feature flag (synchronous after initialization) const isEnabled = featureFlags.checkFlag(user, "new-feature"); // Get multiple flags at once (synchronous) const flags = featureFlags.getFeatureFlags(user, ["feature-a", "feature-b"]); // Shutdown when done await featureFlags.shutdown(); }
The SDK is designed to be resilient and provide fallback behavior:
false for boolean flags)false for non-existent flags1 2// Example error handling try { const isEnabled = featureFlags.checkFlag(user, "new-feature"); } catch (error) { console.warn("Feature flag evaluation failed:", error); // Use safe fallback const isEnabled = false; }
SDK Initialization Fails
development, staging, production)Flags Always Return Default Values
Performance Issues
Rate this page: