Removing GrowthBook
Feature flags are already fully static at runtime — the app reads
src/configs/<tenant>/features.ts (tenant-first, then defaults) via @configs/features.
GrowthBook is used only at build time by scripts/fetch-features.ts (generate:features,
run from prebuild), which re-syncs those committed config files. When offline or without a
client key it skips and uses the committed configs, so the build never depends on the service.
Removing GrowthBook changes nothing at runtime — it only drops the optional
build-time sync. See Capabilities &
Flags for how the
sync works. After removal, features.ts is edited by hand.
Checklist
1. packages/portal-frontend/package.json (required)
Drop the generate:features step from prebuild:
- "prebuild": "pnpm run generate:tsconfig && pnpm run generate:features && pnpm run generate:rewrites && pnpm run generate:deployment-id",
+ "prebuild": "pnpm run generate:tsconfig && pnpm run generate:rewrites && pnpm run generate:deployment-id",Remove the two scripts and the dependency:
"generate:features": "tsx scripts/fetch-features.ts",
"generate:features:all": "tsx scripts/fetch-features.ts --all",
// ...
"@growthbook/growthbook": "^1.6.5",2. Delete the only importer (required)
packages/portal-frontend/scripts/fetch-features.ts3. Dead-code cleanup (optional but recommended)
These reference GrowthBook but are already inert:
src/configs/defaults/storage.ts— removegrowthBookKey: 'growthbook'(used only by the disabled cookie inproxy.ts).src/proxy.ts— remove the two commentedstorageConfig/growthBookKeylines, theGrowthBook UUID cookie (disabled …)doc-comment bullet, and the disabled cookie block beforereturn NextResponse.next().src/configs/defaults/rewrites.ts— the header comment mentions “GrowthBook features”; change to “static feature flags”.scripts/generate-rewrites.ts— drop the(same convention as fetch-features.ts)note.
4. Refresh the lockfile (required)
pnpm installRemoves @growthbook/growthbook from pnpm-lock.yaml.
5. Environment variables (optional)
NEXT_PUBLIC_GROWTHBOOK_CLIENT_KEY, NEXT_PUBLIC_GROWTHBOOK_API_HOST,
NEXT_PUBLIC_GROWTHBOOK_INIT in the .env.* files become unused and can be deleted. They are
secrets — never commit them regardless.
Verify
No source references remain:
grep -rni growthbook packages/portal-frontend/src packages/portal-frontend/scripts(should return nothing, or only text inside committed features.ts comments). Then confirm
the type-check is unchanged:
pnpm --filter portal-frontend type-checkThe app still boots and flags resolve — now solely from the committed
src/configs/<tenant>/features.ts.
After removal
features.ts files become the single source of truth and are edited by hand. To add or flip
a flag, edit src/configs/<tenant>/features.ts (or the defaults one). There is no longer a
command that regenerates them, and the “Generated — do not edit by hand” header no longer applies.