Quick Start
bash npm install expo-build-flags bash yarn add expo-build-flags bash pnpm add expo-build-flags typescript is a peer dependency and should already be in your Expo project.
-
Initialize
bash npx build-flags initbash yarn build-flags initbash pnpm build-flags initThis scaffolds a
flags.ymlat the project root, detects your source directory (src/orapp/), generates the initialbuildFlags.tsmodule, and adds the generated file to.gitignore. -
Define a flag
Open the generated
flags.ymland add a flag:flags.yml mergePath: src/constants/buildFlags.tsflags:newCheckout:value: falsemeta:team: growthmergePathis the relative path where the generated TypeScript module will be written. Thevaluefield is the default boolean state of the flag. -
Generate the runtime module
bash npx build-flags overridebash yarn build-flags overridebash pnpm build-flags overrideThis reads
flags.ymland writes the module at yourmergePath:src/constants/buildFlags.ts // This file is auto-generated by expo-build-flagsexport const BuildFlags = {newCheckout: false,}; -
Use the flag in code
src/screens/checkout.tsx import { BuildFlags } from "../constants/buildFlags";export function CheckoutScreen() {if (BuildFlags.newCheckout) {return <NewCheckoutFlow />;}return <LegacyCheckoutFlow />;} -
Override a flag during development
Prefix a flag name with
+to enable or-to disable:bash npx build-flags override +newCheckoutbash yarn build-flags override +newCheckoutbash pnpm build-flags override +newCheckoutThe generated module now has
newCheckout: true. Your bundle server picks up the change on the next reload.
Your project structure should now look like this:
- flags.yml - src/ - constants/ - buildFlags.ts (generated, gitignored) - screens/ - checkout.tsx - …
Integrate into your dev workflow
Section titled “Integrate into your dev workflow”Since the generated module is gitignored, new contributors won’t have it after cloning. We recommend adding the override command to your postinstall script so it runs automatically after npm install:
{ "scripts": { "postinstall": "build-flags override" }}This ensures every developer has a valid buildFlags.ts without needing to remember a manual step.
What’s next?
Section titled “What’s next?”From here you can layer on additional capabilities:
- Config Plugin — set flags for EAS native builds via an environment variable.
- Babel Plugin — enable tree shaking so disabled features are stripped from production bundles.
- Flagged Autolinking — exclude native modules from autolinking when their flag is off.
- Flag Inversion — invert a flag’s default value for specific bundle IDs.