Feature flags¶
Codebloom has two kinds of feature flags, both set in the backend's Spring config
(src/main/resources/application*.yml):
| Kind | Config key | Read by | Controls |
|---|---|---|---|
| Backend flag | ff.* |
@FF("...") on controller/service methods |
Whether an endpoint is allowed |
| UI flag | ff.ui.* |
The frontend, via js/src/lib/ff |
Whether the UI shows a feature |
They are independent: hiding something in the UI does not block its endpoints, so a feature with backend routes should be gated with both.
How UI flags reach the frontend¶
The backend passes ff.ui through to the browser unchanged, embedded in index.html
when the page loads. The frontend reads it synchronously on startup, so UI flags are
plain booleans: no request and no loading state.
Values are a startup snapshot. Changing a flag takes a backend restart (and a page reload), not a frontend rebuild or redeploy.
Adding a UI flag¶
-
Add the key under
ff.uiinapplication.yml, and override it per environment in the profile files (application-dev.yaml,application-ci.yaml) as needed. No Java changes are required.ff: ui: myFeature: false -
Regenerate frontend types by running the backend with the
devprofile (orjust type-gen). This addsmyFeatureto the generatedUiFeatureFlagstype. -
Export it from
js/src/lib/ff:export const myFeatureFF = runtimeConfig.featureFlags.myFeature; -
If the feature has backend endpoints, also add a backend flag under
ff.*and gate them with@FF.
Key names are passed through exactly
Use the camelCase name the frontend reads (myFeature, not my-feature), and set
UI flags in YAML rather than environment variables. An env var like
FF_UI_MYFEATURE arrives as myfeature, which the frontend doesn't read, so the
feature silently stays off.
Local development¶
just frontend-dev gets the flags from the running backend, so the backend must be up
(CODEBLOOM_BACKEND_URL, default http://localhost:8080). Without it, the Vite dev
server returns an error rather than guessing flag values.