Switchflag
Getting Started

Quickstart

Create your first feature flag and evaluate it in your application in under 5 minutes.

This guide walks you through the essentials: creating an account, setting up a project, defining a flag, and evaluating it with the SDK.

Prerequisites

  • A Switchflag account — sign up here
  • Node.js 18+ installed

1. Create an account

Sign up with your email and password. You'll receive a verification email — click the link to activate your account.

2. Create a project

After signing in, create an organization (or use an existing one), then create a project. Every project comes with three environments by default: development, staging, and production.

3. Create a flag

Navigate to your project's Flags page and click Create Flag. Give it a key like new-checkout-flow, select boolean as the type, and set the default value to false.

Toggle the flag on in your development environment.

4. Install the SDK

npm install @switchflag/sdk

5. Evaluate the flag

import { createClient } from '@switchflag/sdk'

const client = createClient({
  apiKey: 'sf_development_...', // from your environment's API key
})

const result = await client.getFlag<boolean>('new-checkout-flow', {
  userId: 'user-123',
})

console.log(result.value)  // true (flag is enabled)
console.log(result.reason) // 'default' | 'rule_match' | 'disabled' | 'not_found'

The SDK fetches the flag configuration once and caches it in memory. Subsequent calls to getFlag for the same key return instantly from the cache.

Next steps