Documentation

Everything you need to integrate feature flags into your application. From quick start guides to advanced targeting rules.

/

Quick Start Guide

1

Install the SDK

npm install @buildrflags/sdk
2

Initialize the client

flags.ts
import { BuildrFlags } from '@buildrflags/sdk';

const flags = new BuildrFlags({
  apiKey: 'bf_your_api_key',
  environment: 'production'
});
3

Evaluate a flag

app.ts
const isEnabled = await flags.isEnabled('new-feature', {
  userId: user.id,
  email: user.email
});

if (isEnabled) {
  // Show the new feature
}

That's it! You're now ready to ship features with confidence. Create flags in the dashboard and they'll be available instantly.

SDK Reference

Our TypeScript SDK is designed for simplicity and type safety.

Core Methods

isEnabled(key, context)Check if a boolean flag is enabled
getValue(key, context)Get the value of a flag (any type)
getAllFlags(context)Get all flags for a context
identify(context)Pre-fetch flags for a user context

Built-in Caching

60-second default TTL. Configurable per-flag or globally. Reduces API calls while keeping flags fresh.

Automatic Retries

Exponential backoff on failures. Graceful degradation with fallback values. Your app stays responsive.

REST API

Full API access for custom integrations and automation.

Evaluate a flag
GET /api/sdk/flags/:flagKey/evaluate

# Headers
Authorization: Bearer bf_your_api_key
X-Environment: production

# Query params (context)
?userId=user_123&email=user@example.com
GET/flags

List all flags

POST/flags

Create a flag

PUT/flags/:id

Update a flag

Targeting Rules

Target the right users with precise conditions, segment membership, and rollout percentages.

Common conditions

  • plan equals pro
  • country in [US, CA]
  • user_id starts with beta_
  • created_at greater than 2026-01-01

Rollouts + segments

Combine segments with percentage rollouts to gradually enable features for qualified users.

Example: 25% rollout for the “beta_users” segment in production.

A/B Experiments

Design experiments, split traffic across variants, and analyze outcomes with confidence.

Define variants and weights directly in the dashboard.

Track exposures and conversions to calculate lift.

Pause, iterate, or end experiments based on real-time results.

Segments

Build reusable audiences once and apply them across every flag and experiment.

Why segments?

  • Keep targeting logic consistent across teams.
  • Update one segment and every flag stays in sync.
  • Combine segment membership with custom rules.