Your First Flag
Let’s walk through a complete example of adding a feature flag to control a new checkout flow in your app.
The Scenario
You’ve built a new checkout experience and want to:
- Deploy the code to production (safely hidden behind a flag)
- Test it with your team first
- Gradually roll it out to users
- Have an instant kill switch if something goes wrong
Create the Flag
-
Log in to the dashboard
Go to featsync.dev and log in to your account.
-
Navigate to Flags
Click Flags in the sidebar.
-
Create a new flag
Click the Create Flag button and enter:
- Name: New Checkout Flow
- Key:
new-checkout-flow(auto-generated from name) - Type: Boolean (default)
-
Keep it disabled initially
The flag is created in the OFF state. This is intentional - you want to deploy your code first.
Add the Flag to Your Code
Now wrap your new checkout code with a flag check:
import { Featsync } from '@featsync/sdk';
const featsync = new Featsync({ apiKey: process.env.FEATSYNC_API_KEY,});
async function renderCheckout() { if (await featsync.isEnabled('new-checkout-flow')) { return <NewCheckout />; } return <OldCheckout />;}Deploy Your Code
Since the flag is OFF, deploying this code is completely safe. The old checkout will continue showing for all users.
git add .git commit -m "Add new checkout behind feature flag"git push origin main# Deploy to productionEnable for Testing
Now enable the flag to see your new checkout in action:
- Go to the Flags page in the dashboard
- Click on
new-checkout-flowto open the flag detail page - Toggle the environment you want to enable (e.g., Development)
- Click Save Changes
- Visit your app - you should see the new checkout!
Roll Out Gradually (Pro)
Once you’re confident in the new checkout, you can roll it out gradually:
- Upgrade to Pro if you haven’t already
- Edit the flag and set the Percentage to 10%
- 10% of your users will now see the new checkout
- Monitor your metrics
- Increase to 25%, then 50%, then 100%
// For percentage rollouts, use isEnabledForUserconst userId = getCurrentUserId();
if (await featsync.isEnabledForUser('new-checkout-flow', userId)) { return <NewCheckout />;}return <OldCheckout />;Something Wrong? Kill Switch!
If you notice errors or user complaints:
- Go to the flag detail page in the dashboard
- Toggle Production OFF
- Click Save Changes
- All users instantly see the old checkout
No deploy needed. Crisis averted.
Clean Up
Once the new checkout is fully rolled out and stable:
- Remove the flag check from your code
- Delete the old checkout code
- Archive or delete the flag in the dashboard
// Flag removed - new checkout is now the defaultfunction renderCheckout() { return <NewCheckout />;}Next Steps
- Learn about environments to test flags in staging first
- Set up percentage rollouts for gradual releases
- Explore the API reference for all SDK methods