CLI (bake)
Every bake command, the options of bake build and bake dev, what they write per target, and their JSON output.
bake --help lists the commands and bake <command> --help shows one command's options. An app's bake.config.ts lists its targets. Without --target, bake build, bake check, bake package and bake dev use that list, and they refuse a target that is not on it.
| Command | What it does |
|---|---|
bake create | Starts a new app from a template (below) |
bake build | Builds the app for web and native targets (options) |
bake check | Runs the fail-closed checks of bake build for every target in bake.config.ts, without writing bundles (below) |
bake dev | Rebuilds on every saved change and reloads what runs the app (below) |
bake aot | Runs the AOT fast-path check alone (strict by default) |
bake package | Packages an embedded iOS bundle or a standalone desktop app. check and host-check check app packages (Package an app) |
bake release check | Checks a bundle against the installed app package before an OTA release (Package an app) |
bake add, bake diff, bake upgrade, bake remove | Copy a module from a registry into the app (native/<name>/, bake-modules.json), show and merge the registry's changes, remove it (bake add) |
bake registry build | Writes a registry's served files (registry/r/) from its module sources; --check fails when they are stale |
bake native | new writes a module's spec and implementation stubs, gen generates its Swift, Kotlin and Rust contracts, types writes TypeScript declarations from the specs, link writes the host's registration of the modules and views the bundles use, view gen generates a native view's component and platform bases (Native modules) |
bake inspect | Asks a running debug app what only BakeNative knows: views with rects and style, the accessibility tree, errors, perf, the clock, fetch mocks, environment overrides, app state (Working with AI agents) |
bake create [--renderer react|octane] [--targets web,ios,android,mac,windows] [--template tabs] [--dir PATH] [--app-id ID] [--registry URL] [--bakenative PATH] NAME
bake build [-t/--target TARGETS] [--root .] [--out dist] [--hermesc PATH] [--hermesc-flags "-O"] [--json]
[--bake] [--strict-aot | --no-strict-aot] [--viewport 800x600]
[--xcframework] [--name PRODUCT] [--embed-runtime] [--runtime PATH] [--remote-url URL]
bake check [-t/--target TARGETS] [--root .] [--json] [--strict-aot | --no-strict-aot]
bake dev [-t/--target TARGETS] [--root .] [--port 5180] [--open] [--host PATH]
[--udid UDID] [--bundle-id ID] [--ios-host PATH] [--serial SERIAL] [--package NAME]
[--hermesc PATH] [--hermesc-flags "-O0"] [--json] [--once] [--no-strict-aot]
bake aot [--root .] [--json] [--strict-aot | --no-strict-aot]
bake package [-t/--target ios] [--root .] [--out dist] [--runtime PATH] [--json]
bake package --standalone --target mac|windows [--root .] [--out dist] [--bakenative PATH] [--json]
bake package check [--root PATH] [--json] AAR
bake package host-check [--provide NAME=VERSION...] [--platform TYPE] [--json] PACKAGE...
bake release check --against PACKAGE [--json] BUNDLE
bake add [--root .] [--registry URL] [--overwrite] [--dry-run] [--json] MODULE...
bake diff [--root .] [--registry URL] [--stat] [--json] [MODULE]
bake upgrade [--root .] [--registry URL] [--to VERSION] [--dry-run] [--json] [MODULE]
bake remove [--root .] [--force] [--dry-run] MODULE
bake registry build [--dir registry] [--check]
bake native types [--root .] [--schema PATH...] [--out src/native.d.ts]
bake native new [--root .] [--dir DIR] [--target PACKAGE] [--platform all|apple|ios|macos|android|windows|web] [--spec] NAME
bake native gen [--out DIR] [--lang swift|kotlin|rust ...] [--swift-import MODULE...] [--kotlin-package PACKAGE] [--rust-crate CRATE] [--check] SPEC...
bake native link [--root .] -t/--target ios|mac|android|windows [--bundle PATH...] [--out PATH] [--bakenative PATH]
bake native view gen [--out DIR] [--check] SPEC...
bake inspect <tree|a11y|errors|style|layout|hello|list|node|perf|state|clock|net|act|prefer> [args]
[--pid N] [--target TYPE] [--device ID] [--full]Create an app
bake create my-app writes a new app into ./my-app (or --dir, which must be missing or empty).
The default renderer is React. Use bake create my-app --renderer octane for the existing Octane tabs template.
my-app/
package.json selected renderer package, framework dependencies and build scripts
pnpm-workspace.yaml the app's pnpm workspace settings
AGENTS.md, README.md
bake.config.ts the targets the app ships on (--targets)
src/App.tsx React root (src/App.tsrx in the Octane template)
src/styles.css
ios/ XcodeGen project (BakeNativeKit) + build.sh, which copies the baked bundle in (target ios)
macos/ SwiftPM app (BakeNativeAppKit) + build.sh (target mac)
android/ Gradle app with the :bakenative module from your checkout (target android)
native/<module>/ clipboard, haptics, linking and share, added with bake add (bake-modules.json locks them)
bake-modules.json the registry modules the app took, their versions and files
.bake/native/<target> written by bake build: the registration of the modules the bundle uses (git-ignored)
.bake/native/bakenative bake from npm: the prebuilt Apple runtime, unpacked by the ios / mac build (git-ignored)--targets picks the platforms (default: all five, web,ios,android,mac,windows). bake create writes them to bake.config.ts and creates only their host folders. Web has no host folder. The build:<target> scripts in package.json, the README and AGENTS.md cover the same targets. bake create my-app --targets ios,android writes ios/ and android/ and no macos/.
It builds as generated:
cd my-app
pnpm install
pnpm exec bake build --bake # every target in bake.config.tsWith bake installed from npm, web builds and Windows development work as generated. On a Mac with Apple silicon, iOS and macOS projects name .bake/native/bakenative, where pnpm build:ios and pnpm build:mac unpack the prebuilt runtime that came with @bake-native/core (iOS and macOS). The Android and standalone Windows projects point at a BakeNative checkout. See source builds.
--bakenative names a checkout for every native host. It defaults to the checkout the CLI came from; a bake installed from npm has none, so iOS and macOS use the prebuilt runtime, and Android and Windows use ../bakenative next to the app.
--app-id sets the iOS bundle identifier and the Android application id.
The hosts already link the modules in native/ the app calls (bake create adds clipboard, linking, share and haptics). pnpm build:ios, pnpm build:mac, pnpm build:windows and pnpm build:android copy exactly those, with their registration, to .bake/native/<target> (Only the modules an app uses). The Xcode project, the Swift package and the Gradle build depend on it, so starting to call a module needs no host change. Run the build script once before the first Xcode or Gradle build. Until then, Gradle stops with ../.bake/native/android is missing and SwiftPM cannot find the package.
Desktop standalone packages
From an app with a desktop host generated by bake create, run the scaffold script
on the target operating system.
| Target | Scaffold script | Executable |
|---|---|---|
| macOS | pnpm build:mac | dist/standalone/<Product>.app |
| Windows x64 | pnpm build:windows | dist/standalone/windows/<Product>.exe |
The scripts call bake package --standalone --target mac or
bake package --standalone --target windows. Supply one target. The build applies
the standalone app settings, bakes the first
content frame, and packages the runtime and assets. With --json, the report's
standalone path names the .app or Windows distribution directory.
On macOS, install Xcode. Use the prebuilt Apple runtime from the matching toolchain package, or build Hermes and the macOS Rust slice in your source checkout. The .app has an ad hoc signature for local use.
On Windows x64, install Rust with the x86_64-pc-windows-msvc target and Visual
Studio Build Tools with the Windows SDK. Use a matching BakeNative checkout and
Hermes DLLs from the toolchain package or pnpm hermes in the checkout. Distribute
the whole dist/standalone/windows directory. If the directory has no local
Visual C++ runtime DLLs, the destination machine needs the Visual C++
redistributable.
Options
bake package always bakes the first screen. Options for building a standalone Swift package (--xcframework, --name, --embed-runtime, --remote-url) belong to bake build.
| Option | Default | Description |
|---|---|---|
--target, -t | the targets in bake.config.ts, else web,mac (bake package: ios) | Comma-separated: web, ios, android, mac, windows. With a bake.config.ts, each must be in its targets |
--root | . | Project root. The root is src/App.tsx (React) or src/App.tsrx (Octane), plus src/styles.css if present |
--out | dist | Output folder, relative to --root |
--bake | off | Write the first-screen snapshot (app.baked) for every native target |
--viewport | 800x600 | Reference size (WxH) used while baking to find viewport-dependent styles. Not the size the screen is drawn at |
--hermesc | see below | Path to the Hermes compiler |
--hermesc-flags | -O | Flags for hermesc, space-separated; -Xes6-block-scoping is always added (Octane relies on per-iteration let / const bindings). Add -emit-async-break-check to allow timeLimitMs |
--json | off | Print a JSON report instead of human-readable output |
--strict-aot | on | AOT fast-path findings are errors: the build fails before writing a target. On by default; the flag overrides "bakenative": { "strictAot": false } |
--no-strict-aot | off | Turn strict AOT off: findings are warnings and the build continues (also "bakenative": { "strictAot": false } in package.json) |
--xcframework | off | Package the ios / mac targets as a Swift package in dist/<target>-spm (Ship as a Swift package) |
--name | package name | Swift module and product name for --xcframework (example-app becomes ExampleApp) |
--embed-runtime | off | Compile the runtime into <Product>.xcframework instead of shipping BakeNative.xcframework next to it |
--runtime | built and cached | Use an existing BakeNative.xcframework (also $BAKE_RUNTIME_XCFRAMEWORK) |
--remote-url | https://example.com/<Product>/<version> | Base URL of the zips, written to Package.remote.swift |
hermesc is looked up from --hermesc, then $BAKE_HERMESC, then the installed toolchain package (@bake-native/toolchain-<platform>-<arch>, an optional dependency of @bake-native/core), then $BAKE_HERMES_ARTIFACTS, then native/hermes/artifacts of the BakeNative checkout the CLI came from. Native targets fail without it.
Each external tool (bake-css-lint, hermesc, bake-frame, bake-snap) runs with a time limit: 5 minutes for bake-css-lint, 10 minutes for the others. A tool that runs past its limit is stopped, and the build fails with the tool's name, its arguments and the elapsed time. Set BAKE_TOOL_TIMEOUT_<NAME>=<seconds> to change one tool's limit (BAKE_TOOL_TIMEOUT_BAKE_CSS_LINT, BAKE_TOOL_TIMEOUT_HERMESC, BAKE_TOOL_TIMEOUT_BAKE_FRAME, BAKE_TOOL_TIMEOUT_BAKE_SNAP), or BAKE_TOOL_TIMEOUT to change every tool's limit. 0 turns the limit off.
Native React builds always include app.baked. Keep runtime-dependent reads out of the first render. If it throws or fails to commit, the bake stops the build. See React Native migration.
For React, export a named App or a default root from src/App.tsx. For Octane, the root component is the App export of src/App.tsrx, else its default export, else its first exported function.
Output
| Target | Output |
|---|---|
web | dist/web/: a regular Vite site (index.html, hashed assets) |
ios, mac, android, windows | dist/<target>/: app.js, app.hbc, app.css, manifest.json, and app.baked with --bake |
Native output folders are emptied before each build. Each native bundle runs in its host: see iOS, macOS, Android and Windows.
See manifest.json for the manifest fields.
Compile-time constants
| Constant | Value |
|---|---|
import.meta.env.BAKE_TARGET | 'web', 'ios', 'android', 'mac' or 'windows' |
__BAKE_TARGET__ | Same value |
Each native target is a separate build, so code behind a check for another platform is removed.
Control stylesheet
A small stylesheet is loaded before src/styles.css on every target, the browser included. It removes platform appearance from button, input and textarea and gives them a plain background, border and padding, so they look the same everywhere. Controls with class="native" are skipped and stay the platform's own (see Controls). Your CSS overrides it (its rules weigh what a bare button or input selector does).
JSON report and exit codes
With --json, bake prints one object:
{
ok: boolean,
diagnostics: string[], // compiler messages for App.tsrx ("file:line:col: error: …")
compileMs: number,
compiled: string, // the native compile output of App.tsrx
aot: { // the AOT fast-path check (errors that fail the build; warnings when strict AOT is off)
strict: boolean, files: number, warnings: number, errors: number,
off: string | null, // the switch that turned strict off ("--no-strict-aot" or the package.json option)
optOut: string, // strict: how to allow one site or turn strict off; off: "strict AOT is off (…)"
findings: { rule: string, ruleNumber: number, severity: 'warning' | 'error', file: string, line: number, column: number,
endLine: number, endColumn: number, message: string, why: string, fix: string }[],
allowed: { /* same fields */ reason: string | null }[], // sites an bake-allow comment covers
rules: { [rule: string]: { rule: number, title: string, count: number } },
},
targets: {
[target: string]:
| { ok: false, ms: number, diagnostics: string[] } // what went wrong
| {
ok: true, ms: number, dir: string,
// native targets also report:
jsBytes: number, cssBytes: number, hbcBytes: number,
hbcFnv: string, // hash pairing app.hbc with app.baked
hermesBytecode: number, // Hermes bytecode version
hermescMs: number, hermescWarnings: number,
warnings: string[], // hermesc warnings ("app.js:line:col: warning: …"); they do not fail the build
frame: { ms: number, log: string } | null, // bake result with --bake
}
}
}| Exit code | Meaning |
|---|---|
0 | Every target built |
1 | At least one target failed |
2 | Usage error or unexpected exception |
AOT fast-path check
Before it bundles, bake build reads every .tsrx file under src/ with OXC (the parser Octane's compiler runs on) and reports where a template leaves the compiler's AOT path: the template program, the per-binding patchers and auto-memo. The app would still work there, but the runtime takes a slower, generic path. Strict AOT is the default (fail closed): every finding is an error and bake build fails before it writes a target. Strict AOT turns off only when you say so: --no-strict-aot, or "bakenative": { "strictAot": false } in the app's package.json (the command-line flag wins over package.json). Findings are then warnings, the build continues, and the report ends with strict AOT is off (…). bake aot [--root .] [--json] [--strict-aot | --no-strict-aot] runs the check alone. It exits 1 when strict AOT finds something, and 0 when strict AOT is off.
| Rule | Reports | Fix |
|---|---|---|
aot-trackable-expression | A template position (child, prop, @if / @switch / @for value) that calls Math.random(), Date.now(), new Date(), I/O or console, mutates (xs.sort(), x++), calls a local function that does, or reads a let a callback reassigns or a DOM global | Compute the value in state, useMemo or a handler, and read it |
aot-for-key | A @for with no key, keyed by its index, by a constant, by something that does not read the item, or by an impure expression | @for (const item of items; key item.id) |
aot-control-flow | Dynamic tags <{tag}>, a spread / key / children / repeated prop on a host element, JSX chosen or listed inside {…} ({a && <X/>}, {xs.map(…)}), descriptor children | @switch / @if / @for, props written out |
aot-template-program | A @for row that cannot mount as one template program run (mount-template-run) and falls back to one mount-template per row or plain create / insert: a fragment root, @if / @switch / @for or a component inside the row, a ref, two handlers of one event type on a node (onPress + onClick), a handler that can be undefined (c ? f : undefined), a component row that leaves an event prop unset, a text hole that can be non-text ({c && 'x'}) | One element per row; bind differences (class / text ternaries); make the component the row; always pass a function (c ? f : noop); {c ? 'x' : ''} |
aot-static-style | A class built from data ('tab at-' + id, `card-${id}`, .join(' ')), a computed key or spread in a style object, style text assembled at runtime | Whole literal class strings or a token map (AT[key]); style={{ width: w + 'px' }} |
aot-signals | A signal read during render ({count$.get()}, class={c$.get() ? …}, a render-body const from .get() that is only shown in markup), which re-renders the component on every change where a bound handle would update one node; a signal$ / derived$ created during render; a handle passed as an event handler | Bind the handle ({count$}, class={tone$}), or a module-level derived$(() => …); create signals at module scope; onClick={(e) => handler$.get()(e)} |
Rule 4 follows the compiler and runtime, not a re-implementation of the compile-time predicate: rows with inline arrow handlers, calls, casts, style objects or class ternaries still mount as one run. The fixture tests build each rule-4 case for a native target and compare the checker with the mount ops. Markup inside @if (WEB) (const WEB = import.meta.env.BAKE_TARGET === 'web') is dropped from native bundles and is not checked by rules 4 to 6. Reads that decide structure (@if / @for on a signal, a value a handler reads, a component prop) are not reported: only a render can follow them.
Event handlers, ref callbacks, callback props, effects and module code are not checked. Each error prints the file, line and column, the rule and its number, the source line, why it leaves the fast path, how to fix it, and how to allow the site. The summary says how to turn strict AOT off:
✗ src/List.tsrx:10:5 aot-for-key (rule 2)
`@for` has no `key`.
10 | @for (const r of rows) {
| ^^^^^^^^^^^^^^^^^^^^^^^^
why: without a key the compiler synthesizes a positional key: …
fix: add a key from the item's identity: `@for (const r of rows; key r.id)`
allow: // bake-allow aot-for-key -- <reason> on this line or alone on the line above
✗ AOT fast path: 1 error in 1 of 3 .tsrx files (aot-for-key 1); the build fails (strict AOT is the default)
to allow one site: // bake-allow <rule> -- <reason> ({/* … */} inside markup); to turn strict AOT off for the app: --no-strict-aot or "bakenative": { "strictAot": false } in package.jsonWith strict AOT off, the same finding is a warning (⚠), the summary says the build continues, and the last line is strict AOT is off (--no-strict-aot); AOT fast-path findings do not fail the build.
To keep one site, add // bake-allow <rule> -- <reason> ({/* … */} inside markup) on the reported line or alone on the line above. Allowed sites pass in strict mode; they are counted and listed with their reasons.
bake check
bake check runs everything in bake build that fails closed, for every target in bake.config.ts (all five without one, or --target). That covers the AOT fast-path check and, per target, system modules, markup, globals, the UI scope, images, fonts and CSS. It does not run hermesc, bake, or write to dist/: the web build goes to a temporary directory, and native targets stop after their checks. Use it as the gate for every platform the app ships on, on a machine that builds only some of them:
bake check ios, android (the targets in bake.config.ts)
✓ ios 676 ms
✗ android 798 ms
native/linking/Linking.native.ts:1:1: error: the bundle calls native.Linking, but native/linking has no android implementation …The exit codes are those of bake build. --json prints the JSON report without compiled, plus config (the config's file name, or null). A target in the report has ok, ms and, when it passed, checked: true, jsBytes and cssBytes.
bake dev
bake dev watches the project directory, rebuilds the targets on every saved change, and reloads what runs them. Without --target it runs one target: web, or the first target in bake.config.ts when that does not list web. It skips node_modules, dist, .bake and dot directories. Each round prints the time from the save to the new screen:
change src/Counter.tsrx
✓ build 2 windows 1032 ms web 1040 ms
windows save → screen 1162 ms (build 1032 ms, launch → first JS commit 107 ms, pid 15724)
web save → screen 1088 ms (build 1040 ms)
mac save → screen 543 ms (build 407 ms, restart → screen 137 ms, of which process start → first JS commit 136 ms)| Target | What reloads it |
|---|---|
web | A local server on --port serves the build (0 picks any free port). After a good build the page reloads itself, then reports back once it has drawn |
windows | The host exe is started with BAKE_BUNDLE set to the new bundle. After a good build the running app is closed and the exe is started again. The exe is --host, else $BAKE_WINDOWS_HOST, else, in a checkout, the app that pnpm windows -- --no-run staged, else bakenative-app.exe of the installed @bake-native/toolchain-win32-x64 |
mac | The host binary is started with BAKE_BUNDLE set to the new bundle and restarted after every good build. The binary is --host (a binary or a .app), else $BAKE_MAC_HOST, else the debug build of examples/mac (swift build --package-path examples/mac --product MacApp) |
ios | A booted simulator: --udid, else the only booted one. The app --bundle-id (default: examples/ios-brownfield's) is relaunched with simctl launch --terminate-running-process and BAKE_BUNDLE set to the new bundle. The simulator reads it from the Mac, so nothing is copied. --ios-host <App.app> installs a build first |
android | A device or emulator: --serial, else $ANDROID_SERIAL, else the only one adb devices lists. The build is pushed into the app's files directory (adb push, then run-as), and the launcher Activity of --package (default: examples/android's) is restarted with am start -S --es bake_bundle <dir> |
bake dev never boots a simulator or starts an emulator. With several of them running, pass --udid or --serial; it does not pick one for you.
Native hosts
The mac, ios and android hosts must be debug builds that opt in with BakeNativeDev. They run the bundle bake dev passed, and report its first screen. That report ends the save → screen time:
// Swift (BakeNativeKit / BakeNativeAppKit)
#if DEBUG
let bundle = BakeNativeDev.bundle ?? BakeNativeBundle(directory: embedded) // BAKE_BUNDLE
view.onEvent = { BakeNativeDev.report($0) } // `bake-dev shown <phase> <ms> <dir>` on stderr
#endif// Kotlin (dev.bakenative)
val bundle = BakeNativeDev.bundle(activity) ?: BakeNativeBundle.Asset("bakenative/app") // the bake_bundle extra, debuggable apps only
// BakeNativeView.Listener.onLifecycle: BakeNativeDev.lifecycle(phase, detail) // logcat tag BakeNativeDevThe report names the bundle directory. A host that ignored it (a release build, or one without the opt-in) shows its own bundle, and bake dev says so instead of counting it as reloaded. examples/mac, examples/ios-brownfield and examples/android already opt in. The iOS example opens the bundle straight away, without its catalog.
- Failed builds. Compile errors, fail-closed findings and
hermescerrors are printed with their positions. The running app stays on its last good build, and the web page shows the errors over it. Save a fix and the app reloads.hermescwarnings are printed but do not stop the reload. - Bursts of saves. Saves within 40 ms of each other trigger one build. A change during a build starts one more build after it.
- Native code. A changed
.swift,.kt,.rsor C/C++ file is reported but not rebuilt: rebuild the host app. - Bundles. Each build writes a new directory under
.bake/dev, so a running app never has its files deleted under it. Snapshots are not baked.hermescruns with-O0, which is about 3x faster than-O. - State. A reload starts the app again. Component state, text in fields and scroll positions are not kept.
With --json, bake dev prints one event per line instead:
| Event | Fields |
|---|---|
ready | targets, root |
serve | url, port |
change | files |
build | build, ok, ms, diagnostics, and per target ok, ms, diagnostics, warnings, errors |
launch | target, build, pid |
shown | target, build, ms (save to screen), buildMs; windows adds launchMs and pid; mac, ios and android add launchMs (restart to screen), appMs (the app's process start to its first JS commit), phase, and pid, udid or serial (android also pushMs) |
log | target, line (the app's output) |
exit, notice | the app exited; anything else worth saying |
--once builds, waits for the first screen and exits. The exit code is 0 when every target showed it.