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.
Get started with feature flags in your Forge app. You'll create a simple toggle that controls a welcome message without redeploying your app.
What you'll build: A feature flag that shows/hides a premium welcome message
Time: 10 minutes
You need:
Install required packages:
1 2cd your-forge-app npm install @forge/feature-flags-node@latest
Update your resolver code to include the feature flag SDK initialization and flag evaluation logic. Replace your src/resolvers/index.js:
1 2//src/resolvers/index.js import Resolver from '@forge/resolver'; import { ForgeFeatureFlags } from "@forge/feature-flags-node"; const resolver = new Resolver(); resolver.define('getFlagValue', async ({ payload, context }) => { const featureFlags = new ForgeFeatureFlags(); await featureFlags.initialize({ environment: context?.environmentType?.toLowerCase() || "development" }); const user = { identifiers: { installContext : context?.installContext }, attributes: { installContext : context?.installContext } } return featureFlags.checkFlag( user, payload?.flag, false); }); export const handler = resolver.getDefinitions();
Update your frontend code to include feature flag logic. Replace your src/frontend/index.jsx:
1 2// src/frontend/index.jsx import React, { useEffect, useState } from 'react'; import ForgeReconciler, { Text } from '@forge/react'; import { ForgeFeatureFlags, view } from '@forge/bridge'; const App = () => { const [showPremium, setShowPremium] = useState(false); const [loading, setLoading] = useState(true); useEffect(() => { invoke('getFlagValue', { flag: 'show_premium_welcome' }) .then((value) => { setShowPremium(value) setLoading(false); }) .catch(() => { console.error('Feature flag error:'); setShowPremium(false); setLoading(false); }); }, []); if (loading) { return <Text>Loading...</Text>; } return ( <> <Text>Hello world!</Text> {showPremium && ( <Text appearance="success">🎉 Welcome to Premium Features!</Text> )} </> ); }; ForgeReconciler.render( <React.StrictMode> <App /> </React.StrictMode> );
What this code does:
installContext from the contextForgeFeatureFlags with user context and environment in the resolvershow_premium_welcome flagDeploy your app with the feature flag code:
1 2forge deploy forge install --upgrade
Your app is now deployed with feature flag code, but the flag doesn't exist yet (it will default to false).
Now create the feature flag in Developer Console:
show premium welcomeControls premium welcome message visibilityinstallContextThe Flag ID (show_premium_welcome) is automatically generated from the name you provide.
100% and Fail to 0%Refresh your app - You should now see: "🎉 Welcome to Premium Features!"
Test the toggle:
show_premium_welcome0%, Fail to 100%100%, Fail 0%Congratulations! You've successfully implemented your first feature flag. Here's what to explore next:
new-dashboard-layout, checkout-v2team-dashboard-redesignYou're now ready to use feature flags in your Forge apps! Start experimenting with different flag configurations and rollout strategies.
Rate this page: