Feature Flags Configuration
The feature flags the kit exposes, where they come from, and how to read and add them.
Feature flags are built by getFeatureFlags() in apps/web/config/feature-flags.config.server.ts, from environment variables and the account mode.
This page is part of the Configuration documentation.
Current Flags
| Flag | Source |
|---|---|
enablePersonalAccount | ACCOUNT_MODE |
enableOrganizations | ACCOUNT_MODE |
allowUserToCreateOrganization | ACCOUNT_MODE |
showAccountSwitcher | ACCOUNT_MODE |
enableOrganizationsBilling | ACCOUNT_MODE + both Stripe keys |
enablePersonalAccountBilling | ACCOUNT_MODE + ENABLE_PERSONAL_ACCOUNT_BILLING + both Stripe keys |
enableOrganizationDeletion | ACCOUNT_MODE |
enableThemeToggle | ENABLE_THEME_TOGGLE |
How the account-mode flags are derived: Account Modes.
Reading Flags
// server: loaders, actions, handlers, servicesimport { HTTPException } from 'hono/http-exception';import { getFeatureFlags } from '#/config/feature-flags.config.server.ts';if (!getFeatureFlags().enableOrganizations) { throw new HTTPException(404);}// browserimport { useShared } from '@void/react';const { config } = useShared();return config.flags.enableThemeToggle ? <ModeToggle /> : null;A flag hides UI; it doesn't protect anything. Check the flag (and the user's permissions) again in every action and handler that the hidden UI would call.
Flags Are Public
Every flag is sent to the browser: public-config.server.ts passes getFeatureFlags() through whole. Never put a secret, an internal id or a per-user value in it.
Adding a Flag
- Declare the variable with a default in
apps/web/env.ts, e.g.ENABLE_REFERRALS: boolean().default(false). - Add it to
apps/web/env.example. - Read it in your own server code, or add it to
createFeatureFlags()if it should appear ingetFeatureFlags()and in the browser (that file is kit-owned, so expect to resolve it when you merge kit updates). - Turn it on per environment with
void secret put ENABLE_REFERRALS.
Common Pitfalls
- Treating a flag as authorization: check it again in the action.
- Putting a secret in a flag: every visitor can read
useShared().config.flags. - Overriding one account-mode flag on its own: change
ACCOUNT_MODEinstead. - Expecting a flag change to need a rebuild: flags are server env, so a new secret value applies to new Worker isolates without rebuilding.