Documentation for feature flag integration in the Ambient Code Platform.
Use Unleash to enable or disable features without redeploying:
- Frontend: Next.js proxy at
/api/feature-flags; useuseFlag()/useVariant()from@/lib/feature-flagsin client components - Backend: Go SDK; use
handlers.FeatureEnabled()orhandlers.FeatureEnabledForRequest()in handlers - Admin UI: Manage feature toggles directly from the workspace UI (see below)
- Workspace overrides: ConfigMap-based per-workspace overrides take precedence over Unleash global state
- When Unleash is not configured, general flags are disabled (fail-closed) and model flags remain enabled (fail-open). See fail-modes.md for details.
Environment variables: UNLEASH_URL, UNLEASH_CLIENT_KEY (and optionally UNLEASH_APP_NAME for frontend). See the guide for per-component details.
The platform includes a built-in admin UI for managing feature flags directly from the workspace. Navigate to Workspace > Feature Flags to:
- View all feature toggles and their current state
- Enable/disable toggles with a single click
- See toggle types (release, experiment, operational, kill-switch)
- View toggle descriptions and stale status
Additional environment variables for Admin UI:
| Variable | Required | Description |
|---|---|---|
UNLEASH_ADMIN_URL |
Yes | Unleash server base URL (same as UNLEASH_URL typically) |
UNLEASH_ADMIN_TOKEN |
Yes | Admin API token (different from Client API token) |
UNLEASH_PROJECT |
No | Unleash project ID (default: default) |
UNLEASH_ENVIRONMENT |
No | Target environment for toggles (default: development) |
To get an Admin API token, go to Unleash UI > Admin > API tokens and create a token with Admin permissions.
Set environment variables for the components you use:
Frontend (ConfigMap/Secret or .env.local):
UNLEASH_URL=https://unleash.example.com
UNLEASH_CLIENT_KEY=your-frontend-api-tokenBackend (ConfigMap/Secret):
UNLEASH_URL=https://unleash.example.com
UNLEASH_CLIENT_KEY=your-client-api-tokenIn the Unleash UI, create a feature toggle (e.g. my-feature). Enable or disable it at any time; no redeploy needed.
Frontend (client component):
import { useFlag } from '@/lib/feature-flags';
const enabled = useFlag('my-feature');Backend (handler):
if handlers.FeatureEnabled("my-feature") {
// new behavior
}- Unleash Integration Guide — Setup, usage in frontend/backend, admin UI, API endpoints
- Fail Modes Reference — Which methods fail open vs closed, where each is used, evaluation precedence
- Frontend README – Development and env overview
- Backend README – Development and env overview
- Architecture – System design
- Unleash: https://docs.getunleash.io/
- Unleash Go SDK: https://pkg.go.dev/github.com/Unleash/unleash-go-sdk/v5
- Unleash React SDK: https://docs.getunleash.io/sdks/react