SDK
Installation
Install the Switchflag SDK and understand its requirements and export paths.
Install
npm install @switchflag/sdkRequirements
- Node.js 18+ (for native
fetchsupport) - ESM only — the SDK ships as ES modules (
"type": "module")
Export paths
The package provides two separate entry points:
| Import Path | Use Case |
|---|---|
@switchflag/sdk | Standard client for Node.js servers and long-lived processes |
@switchflag/sdk/edge | Edge 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 instancegetFlag— singleton function (requiresinit()first)SwitchflagClient— client interface typeClientConfig— configuration typeEvaluationContext— 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 functionEdgeConfig— edge configuration typeEvaluationContext— context typeEvaluationResult— result type