Bundle a flow’s JSON
Unlike iOS (which loads a bundle resource by name), React Native has no “bundle resource by name” lookup. Pass the flow JSON directly, typicallyrequire('./flows/onboarding.json') (Metro inlines it as a plain object).
Declare it at configure time:
() => object | null) is accepted for lazy loading.
Export a fully-offline bundle with flowpilot-export
flowpilot-export snapshots a placement’s default flow (the deterministic default, not an A/B variant) plus its images, icons, and fonts into a self-contained .flowassets folder. Run it on a dev machine or in CI; it is never part of your app bundle.
Flags
The command writes
flow.json, manifest.json, the downloaded asset files, and a generated index.ts that exports a ready-to-use asset bundle.
Exit codes
Register the exported bundle
The generatedindex.ts exports a named asset bundle (the command prints the exact name and a ready-to-paste snippet). Register it as the third argument to registerBundledFlow:
bundledFlowAssets, keyed by the same placement key:
FlowPilot.registerBundledFlowAssets('onboarding', onboardingDefault).
What an asset bundle is
ABundledFlowAssets is a manifest plus a resources map. The manifest lists the flow’s image/icon/font references; resources maps each manifest resource path to a require()’d Metro asset (a module number) or a local uri string. The exporter builds this for you; the shape if you author it by hand:
The exporter and the runtime seeder share the same asset enumeration and URL resolution logic, so “what the export downloads” and “what the app looks up at render time” cannot drift out of sync.
Common mistakes
- Bundling JSON but not assets. The flow renders offline, but images, icons, and fonts go blank or fall back to system fonts. Ship the
.flowassetsbundle too. - Pointing
requireat the wrong path.require('./assets/.../flow.json')must resolve at build time. Metro inlines it; a dynamic path will not work. - Expecting the export to include an A/B variant. The exporter snapshots the deterministic default flow only. Variants resolve live.
- Ignoring exit code 3 in CI. A partial export still writes a usable bundle but some assets failed to download. Treat
3as a warning to investigate. - Running
flowpilot-exportagainstdevelopment. It works, but make sure the placement has a published default flow on whatever environment you point at.
Troubleshooting
- Offline render shows blank images. No asset bundle, or the manifest
resourcepaths do not match theresourcesmap keys. Re-export and register the generated bundle. - Fonts fall back to system offline. The font is not in the bundle’s
fontsmanifest. Re-run the export so it includes the font variants the flow uses. flowpilot-exportexits2. A required flag is missing or--envis unknown. Runnpx flowpilot-export --help.flowpilot-exportexits1. Resolve/decode/write failed. Check the API key, app id, placement key, and that a default flow is published.