Switchflag
SDK

Installation

Install the Switchflag SDK and understand its requirements and export paths.

Install

npm install @switchflag/sdk

Requirements

  • Node.js 18+ (for native fetch support)
  • ESM only — the SDK ships as ES modules ("type": "module")

Export paths

The package provides two separate entry points:

Import PathUse Case
@switchflag/sdkStandard client for Node.js servers and long-lived processes
@switchflag/sdk/edgeEdge client for Vercel Edge Functions, Cloudflare Workers, etc.
// Standard
import { createClient, getFlag } from '@switchflag/sdk'

// Edge
import { evaluateAtEdge } from '@switchflag/sdk/edge'

What's included

The standard entry point (@switchflag/sdk) exports:

  • createClient — create a configured client instance
  • getFlag — singleton function (requires init() first)
  • SwitchflagClient — client interface type
  • ClientConfig — configuration type
  • EvaluationContext — context type (re-exported from @switchflag/shared)
  • EvaluationResult — result type (re-exported from @switchflag/shared)

The edge entry point (@switchflag/sdk/edge) exports:

  • evaluateAtEdge — stateless edge evaluation function
  • EdgeConfig — edge configuration type
  • EvaluationContext — context type
  • EvaluationResult — result type