Basic Feature Flags
Learn how to use simple on/off feature toggles with FlagVault SDK
Cached vs Real-time Flag Evaluation
Compare how caching affects flag response behavior
The cached flags use HTTP cache headers and SDK cache, while real-time flags bypass caching for immediate updates
Cached Flags
5 min TTL
These flags are cached: Changes in your dashboard may take up to 5 minutes to reflect here. This improves performance but reduces real-time accuracy.
demo-feature
SDK not initialized
beta-features
SDK not initialized
Real-time Flags
No Cache
These flags update immediately: Changes in your dashboard will reflect within seconds. This provides real-time accuracy but may be slower.
new-ui-design
Checking...
maintenance-mode
Checking...
When to Use Each Strategy
✅ Use Cached Flags For:
- • High-traffic features
- • Performance-critical code paths
- • Features that don't need instant updates
- • Reduced API costs
⚡ Use Real-time Flags For:
- • Emergency kill switches
- • Security-related features
- • Critical user-facing changes
- • A/B test result accuracy
Custom Flag Check
Enter your own flag key to check its status
Implementation Examples
Code snippets showing how to implement cached vs real-time flag evaluation
Cached Flag Evaluation (Recommended)
import FlagVaultSDK from '@flagvault/sdk';
// SDK with caching enabled (recommended for most use cases)
const sdk = new FlagVaultSDK({
apiKey: 'test_your-api-key-here',
cache: {
enabled: true,
ttl: 300, // 5 minutes cache
maxSize: 1000,
refreshInterval: 60 // 1 minute background refresh
}
});
// Cached flag evaluation - fast but may be slightly stale
const isEnabled = await sdk.isEnabled('demo-feature');
if (isEnabled) {
showNewFeature();
} else {
showOldFeature();
}Real-time Flag Evaluation (Critical Features)
import FlagVaultSDK from '@flagvault/sdk';
// SDK with minimal caching for real-time updates
const realtimeSdk = new FlagVaultSDK({
apiKey: 'test_your-api-key-here',
cache: {
enabled: false // Disable cache for immediate updates
}
});
// Real-time flag evaluation - slower but always current
const isMaintenanceMode = await realtimeSdk.isEnabled('maintenance-mode');
if (isMaintenanceMode) {
showMaintenancePage();
} else {
showNormalApplication();
}Graceful Error Handling
// No try/catch needed - errors are handled gracefully
const isEnabled = await sdk.isEnabled('my-feature-flag', false);
// On network error, you'll see:
// FlagVault: Failed to connect to API for flag 'my-feature-flag', using default: false
// On authentication error:
// FlagVault: Invalid API credentials for flag 'my-feature-flag', using default: false
// On missing flag:
// FlagVault: Flag 'my-feature-flag' not found, using default: falseHow It Works
Understanding the feature flag lifecycle
- 1SDK makes a GET request to
https://api.flagvault.com/api/feature-flag/{flag-key}/enabled - 2API validates your credentials and checks the flag status in the selected environment
- 3Returns a boolean value indicating if the flag is enabled
- 4On error, returns the default value you specified (graceful degradation)