Create Your First Flag
This guide walks through creating a feature flag, enabling it per environment, adding targeting rules, and evaluating it from your application.
Step 1: Register and Set Up
After installing FeatureSignals, register at https://app.featuresignals.com. Registration automatically creates:
- Your user with owner role
- A default organization
- A Default Project with environments:
dev,staging,production
Step 2: Create a Flag
Navigate to Flags and click Create Flag.
| Field | Value | Description |
|---|---|---|
key | dark-mode | Unique identifier used in code |
name | Dark Mode | Human-readable label |
type | boolean | Flag type |
default_value | false | Returned when the flag is disabled |
The flag key is immutable after creation and is what your SDKs reference.
Step 3: Enable Per Environment
Flags are disabled by default in all environments. To enable:
- Open the flag detail page
- Select the dev environment tab
- Toggle Enabled to ON
- The flag now returns
truefor all users indev
Step 4: Add Targeting Rules
Targeting rules let you return specific values based on user attributes:
- In the flag's dev environment, click Add Rule
- Configure: Condition:
countryequalsUS, Value:true - Save
Now only users with country: "US" in their evaluation context get true.
Step 5: Evaluate from Code
import { FeatureSignalsClient } from '@featuresignals/node';
const client = new FeatureSignalsClient('fs_srv_...', {
envKey: 'dev',
baseURL: 'https://api.featuresignals.com',
});
await client.waitForReady();
// User from US gets targeting rule match
const usUser = client.boolVariation('dark-mode', {
key: 'user-1',
attributes: { country: 'US' }
}, false);
// → true
// User from UK falls through to default
const ukUser = client.boolVariation('dark-mode', {
key: 'user-2',
attributes: { country: 'UK' }
}, false);
// → falseThe keyfield is required and uniquely identifies the user. It's used for percentage rollouts and A/B variant assignment via consistent hashing.
Step 6: Gradual Rollout
Instead of enabling for all users, do a percentage rollout:
- Set Percentage Rollout to
2500(25%) - Save
Now 25% of users (deterministically based on their key) see true.
Understanding Evaluation Reasons
| Reason | Meaning |
|---|---|
DISABLED | Flag is off in this environment |
TARGETED | Matched a targeting rule at 100% |
ROLLOUT | Matched via percentage rollout |
FALLTHROUGH | Flag enabled but no rules matched |
NOT_FOUND | Flag key doesn't exist |
PREREQUISITE_FAILED | A prerequisite flag condition wasn't met |
MUTUALLY_EXCLUDED | Another flag in the mutex group won |
VARIANT | A/B experiment variant assigned |