SDK
togglebit
TypeScript-first npm package under 2kb gzipped. React hooks for client components, a zero-dependency server helper for RSC and route handlers.
- useFlag hook
- getFlag for server
- Built-in LRU cache
- Fails safe to off
Personal project · Feature flags for Next.js
Togglebit is a feature flag platform I built to separate deploys from releases. Wrap new logic behind a flag, roll it out gradually, and turn it off instantly when something breaks.
SDK · API · Dashboard · npm install togglebit
checkout-v2
EnabledType
Combined
Env
prod
Rules
plan=pro
Deploying code and releasing a feature are not the same thing. You can merge today and expose the change to 5% of users tomorrow, or keep it off until QA signs off. When a rollout misbehaves, you flip a switch instead of rolling back an entire deploy.
Merge to main on your schedule. Turn the feature on when you are ready.
Start with internal users, a beta cohort, or a small percentage before going wide.
Disable a bad path in seconds from the dashboard while the rest of your app keeps running.
Togglebit is a full stack I designed and built: a lightweight SDK for your app, a fast evaluation API, and a dashboard to manage everything.
SDK
togglebit
TypeScript-first npm package under 2kb gzipped. React hooks for client components, a zero-dependency server helper for RSC and route handlers.
API
FastAPI
Python backend with a Redis-cached evaluation path and Postgres as source of truth. API keys for SDK access, Clerk JWT for dashboard management.
Dashboard
Next.js
Management UI where you create flags, tune rollouts, generate API keys, and invite teammates. Includes a built-in quickstart with copy-paste snippets.
Everything below is implemented and working. This is not a mockup or a slide deck.
Install with npm, add your API key, and evaluate flags in a few lines. The package ships dual entry points so server code never pulls in React.
Client component
'use client'
import { useFlag } from 'togglebit'
export function Checkout() {
const v2 = useFlag('checkout-v2', { userId: user.id })
return v2 ? <NewCheckout /> : <LegacyCheckout />
}Server component
import { createTogglebit } from 'togglebit/server'
const togglebit = createTogglebit({
apiKey: process.env.TOGGLEBIT_API_KEY!,
environment: 'prod',
})
const enabled = await togglebit.getFlag('checkout-v2', {
userId: user.id,
plan: 'pro',
})Name it, pick a type (boolean, percentage, segment, or combined), and configure each environment in the dashboard.
Wrap your app with TogglebitProvider and call useFlag on the client, or getFlag in a server component.
Start at 0%, watch how it behaves, then increase exposure or flip the kill switch if needed.
The dashboard includes a full quickstart with your API key pre-filled. Here is the short version.
Use the dashboard to set up your workspace and invite teammates if you want.
Pick an environment (dev, staging, or prod). Copy the key immediately; it is only shown once.
Run npm install togglebit, add the provider, and check your first flag in under a minute.
A runtime switch that lets you turn code on or off without redeploying. Your app asks Togglebit whether a flag is enabled for a given user, and you branch accordingly.
The SDK is built for Next.js App Router first, with React hooks for client components and a separate server entry for RSC. The evaluation API itself is framework-agnostic if you call it directly.
The SDK fails safe: any network error or missing flag defaults to off. Your app keeps running; the new feature just stays hidden.
Not yet. The Python API backend is live, and a Python client is planned. For now, use the TypeScript SDK or call the REST eval endpoint directly.
Yes. The whole stack runs via Docker Compose: nginx, API, dashboard, Postgres, and Redis on a single port. See the repo README for deployment.
No. Togglebit is a personal project I built to learn full-stack system design and ship something real. The dashboard is open for anyone curious to explore.
Create a flag, generate a key, and follow the quickstart. No pitch deck, no sales call. Just the product.