Config (bake.config.ts)
Choose a renderer, targets and fonts for a BakeNative app.
An app can have a bake.config.ts at its root, next to package.json. It lists the platforms the app ships on:
import { defineConfig } from '@bake-native/react';
export default defineConfig({
targets: ['web', 'ios', 'android'],
renderer: 'react',
});bake create writes one with the targets you pick (--targets, default: all five). An app without the file builds exactly as before, with each command's own defaults.
renderer
Use renderer: 'react' with src/App.tsx or renderer: 'octane' with src/App.tsrx. With a single root file the CLI can infer the renderer. When both files exist, select one explicitly. Import defineConfig from the corresponding adapter root. A native React build always bakes its first frame. The Octane-specific compiler.strong option is described below.
fonts
List bundled faces by name or give a custom face with an app-relative path. Each face is available to the host before it draws the first frame.
import { defineConfig } from '@bake-native/react';
export default defineConfig({
targets: ['web', 'ios', 'android'],
fonts: [
'geist',
'geist-mono',
{ family: 'Brand', src: './assets/Brand.ttf', weight: [100, 900], style: 'normal' },
],
});The bundled names are geist, geist-italic, geist-mono and geist-mono-italic. For a custom file, weight accepts a number or a two-number range and defaults to 400. style accepts 'normal' or 'italic' and defaults to 'normal'. TTF and OTF work on every target. WOFF2 works on web, iOS, macOS and Windows. WOFF works on the web. Refer to the face by its family name in your styles.
targets
targets is a list of 'web', 'ios', 'android', 'mac' and 'windows'. Each appears at most once. Default: ['web'].
| Command | Without --target | With --target |
|---|---|---|
bake build | Builds every target in the list | Every target given must be in the list |
bake check | Checks every target in the list | Every target given must be in the list |
bake package | Packs the listed targets it can pack (ios); an error when there is none | Must be in the list |
bake dev | One target: web when listed, else the first in the list. Each target starts a device or a host window, so name more with --target | Must be in the list |
bake native link | (--target is required) | Must be in the list |
A target outside the list stops the command before it does anything:
this app does not target windows; add it to targets in bake.config.ts (declared: web, ios, android)bake aot has no --target: the AOT fast-path check reads the sources once for every target. bake native new --target names a Kotlin package, not a platform, so the list does not apply to it.
Checking every declared target
bake check runs everything in bake build that can fail closed, for every listed target. That is the AOT fast-path check, then, per target, system modules, markup, globals, the UI scope, images, fonts and CSS. It needs neither hermesc nor a bake, and it writes nothing to dist/. A module that one listed target's host does not implement fails that target only:
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 …bake build with no --target runs the same checks on the same targets, because it builds each of them. Without a config, bake check checks all five targets.
app
Use app for standalone native projects created by bake create. Set an ID for each
native target through app.appId or its platform override.
iOS and Android
Use app.ios.appId and app.android.appId to override the shared ID. Preserve the ID
from the existing store listing when migrating an app. Setting Android's application
ID leaves the Kotlin namespace intact.
export default defineConfig({
targets: ['ios', 'android'],
compiler: { strong: true },
app: {
name: 'My App',
appId: 'com.example.myapp',
icon: './assets/icon.png',
splash: {
backgroundColor: '#0e0e0f',
image: './assets/splash-icon.png',
},
ios: { appId: 'com.example.myapp.ios' },
android: {
adaptiveIcon: {
foregroundImage: './assets/icon-foreground.png',
backgroundColor: '#0e0e0f',
},
},
},
});Use PNG paths relative to bake.config.ts. iOS requires a 1024×1024 app icon.
Android uses icon for a regular launcher icon, or adaptiveIcon for a
foreground layer with a masked background. On both platforms, splash.image
is optional. With Android 12 and later, the system uses the launcher icon
when you set a background color alone. The OS controls the launch image's
size and mask. Expo launch asset guide
The generated iOS project uses asset catalogs and the native launch screen
configuration. The Android project reads the application ID and resources
from dist/android/native-app. Run the app's build script before native
packaging. The launch screen appears before the BakeNative view. BakeNative still
bakes and adopts the first content frame independently.
macOS and Windows
app.mac.appId sets the macOS bundle identifier. app.windows.appId sets the
Windows executable manifest identity and the process's AppUserModelID. Both default
to app.appId. Set app.name to control the display name and window title.
Use app.mac.icon for an .icns file and app.windows.icon for an .ico file,
with paths relative to bake.config.ts. The host uses the same icon for the
tray when configured. The shared PNG app.icon is for iOS and Android.
export default defineConfig({
targets: ['mac', 'windows'],
app: {
name: 'Example App',
appId: 'com.example.desktop',
mac: { icon: './assets/app.icns' },
windows: { icon: './assets/app.ico' },
desktop: {
window: {
startVisible: false,
titleBar: 'hidden',
showInTaskbar: false,
alwaysOnTop: true,
},
tray: {
click: 'toggle',
menu: [
{ label: 'Stop syncing', action: 'app', id: 'stop-sync' },
{ label: 'Show window', action: 'show' },
{ label: 'Quit', action: 'quit' },
],
},
},
},
});| Setting | Default | Behavior |
|---|---|---|
window.startVisible | true | Show the window at launch. |
window.titleBar | 'system' | Use native chrome. 'hidden' hides the title and caption buttons. |
window.showInTaskbar | true | Show the app in the macOS Dock or the window in the Windows taskbar. |
window.alwaysOnTop | false | Use a floating macOS window or a topmost Windows window. |
tray | Omitted | Add an icon to the macOS menu bar or Windows notification area. Closing a window with a tray hides it. |
tray.click | 'menu' | Open the menu on primary click. 'toggle' shows or hides the window on primary click. Secondary click opens the menu. |
tray.menu | Show, Hide, Quit | Set the labels and order of show, hide, toggle, quit and app actions. |
A window that starts hidden or is excluded from the Dock or taskbar needs a tray.
When primary click opens the menu, include a show or toggle item.
For an app action, give the item a lowercase ID and handle it in the generated
macOS handleTrayAction(_:) or Windows handle_tray_action function. The host
invokes the handler on its UI thread even while the window is hidden. Call your
native app service there and move long-running work off the UI thread.
Run pnpm build:mac on macOS or pnpm build:windows on Windows x64 to create
the standalone app. The scripts call bake package --standalone. See
desktop packaging for the build
requirements and output paths.
Embedded apps omit app. Plain bake package and XCFramework builds reject app
settings because the embedding app owns the executable identity, icons, system
splash, tray, and window.
android
android.minSdk is the lowest Android API level the app runs on: an integer from 29 (the BakeNative host's own minimum) to 37. Default: 29.
export default defineConfig({
targets: ['web', 'android'],
android: { minSdk: 31 },
});- The CSS check follows it. Android draws
filter: blur()anddrop-shadow()withRenderEffect, which API 29 and 30 do not have. Below 31 they are a build error (css-effects-host) that tells you to raiseminSdkto 31; from 31 they build. - The APK gets it.
bake build --target android(andbake native link --target android) writes the value into the generated.bake/native/androidmodule: the module declares it as its ownminSdk, and itsmin-sdkfile holds it for the app. The app template'sapp/build.gradle.ktsreadsmin-sdkfor itsminSdk. A host app that keeps a lowerminSdkof its own fails the manifest merge instead of shipping effects its oldest devices cannot draw.
locales
export default defineConfig({ targets: ['ios', 'android'], locales: ['en', 'ko'] });The languages the app ships, as BCP 47 tags. The first is the default. Without locales the app has one locale, en, and one first screen, as before.
- A first screen per locale.
bake build --bakebakes the default locale's first screen asapp.bakedand every other one asapp.<tag>.baked.manifest.jsonlists them inlocalesandframes. - One locale per screen. The core resolves it once, before the first render. It takes the user's preferred languages in order, the app's own language setting included, and picks the first that matches a locale exactly or by language and script. If none matches, it picks the default. The host opens that locale's first screen. It never opens another language's: without one, the screen mounts from JavaScript.
locale()anddir()from@bake-native/octanereturn the resolved tag and the document's writing direction synchronously. The direction defaults to the locale's direction. The web usesnavigator.languagesas its language preferences. Initialize your translation library fromlocale()and include its strings in the bundle.setLocale(tag)saves a tag fromlocaleson web, iOS, macOS, Android, and Windows. Passnullor''to clear the choice and follow the device's languages again. The running screen keeps its locale. A saved tag takes precedence on the next native process launch or web reload. On the web, persistence requires access tolocalStorage.- Right to left on iOS, macOS, Android and the web. A right-to-left locale (
ar,he,fa, ...) sets the document's direction, in the bake and on the device. Including Windows intargetsmakes a right-to-left locale a config error.
Errors name the place: an empty or non-array locales, a value that is not a language tag, a repeat (case-insensitive) and a right-to-left locale with a Windows target. setLocale throws a RangeError for a tag that is not one of locales.
bake
export default defineConfig({ targets: ['ios'], bake: false });App-wide Strong mode requires a baked first screen on every requested native target and rejects bake: false. For other apps, this controls whether bake build --bake bakes the first screen. Default: true. The first screen is the root component's first render, so the switch covers the whole bundle. Set false for an app whose first render must read a runtime value (the host's props, the clock, native state): it has no baked first screen, and its first render gets the host's props. Otherwise give the value a default and read it after the first render (Runtime values).
registries
Native module registries besides the official one, by alias. bake add <alias>/<name> copies a
module from one (Other registries). A value is an https
URL or a directory holding the registry's index.json; an alias is lowercase letters, digits and
dashes. Setting bakenative replaces the official registry. A private registry takes
{ url, headers }; ${NAME} in a header is read from the environment when bake sends the request,
so tokens stay out of the config and the lock:
export default defineConfig({
targets: ['web', 'ios', 'android'],
registries: {
acme: { url: 'https://acme.dev/r', headers: { Authorization: 'Bearer ${ACME_TOKEN}' } },
},
});direct
A signal bound to the inline transform or opacity of an element or a built-in View, Text or
Image (style={{ transform: t$ }}, holding a numeric transform from @bake-native/octane or a
number) moves the native view without a batch
or a commit wherever nothing else owns that property: no transition or animation on it, no
translate / rotate / scale, no rule over the inline value. Apps write nothing for it; every
other value keeps the batch path. The build uses direct updates when the app's own
src/**/*.tsrx binds such a signal; a binding inside a dependency package keeps the batch path.
export default defineConfig({
direct: false, // off for the whole app
// direct: { exclude: ['src/legacy/**'] } // off for the matching files (globs from the app root)
});Default: on.
compiler
For Octane apps, BakeNative reads the Octane compiler settings. compiler.strong enables
Strong Mode for the app, and
compiler.strongDependencies sets the compiler's dependency policy. These apply
to every target in bake build, bake check, bake dev and bake package.
The Octane scaffold enables Strong Mode here. Existing package-level Strong declarations
continue to be read by Octane.
With app-wide Strong enabled, native bake build and bake package bake automatically.
Every declared locale must produce a frame that a fresh Hermes runtime can adopt with the
shipped bytecode. Synchronous module initialization and the root render must use deterministic
inputs. Read the clock or query native availability in a handler after the first commit.
A failed validation preserves the previous successful bundles. bake check checks the
source and target support; the native build performs the Hermes verification.
Octane options for SSR, routing, adapters and renderer selection belong to the
Octane bundler integrations. bake reports an error when a config asks it to
apply options that its targets do not implement.
Finding and loading the file
bake looks for bake.config.ts, .mts, .cts, .js and .mjs in --root (default: the current directory). Rename a legacy octane.config.* or oct.config.* file to bake.config.*. The CLI recognizes the old names and prints a migration notice. Two config files in one root are an error. It does not look in parent directories, so a monorepo's own config is never another app's. The search uses unconfig. The file must have a default export.
Node loads TypeScript itself, by stripping types; bake does not ship a TypeScript compiler. So the file must use erasable syntax only:
- import types with
import type(import type { BakeConfig } from '@bake-native/react'), or usedefineConfig, which types the object for you; - no
enum,namespaceor parameter properties.
If you disable Node's type stripping with --no-experimental-strip-types, bake strips the types into a temporary file next to the config, imports it, and deletes it.
defineConfig and the types BakeConfig, BakeAndroidConfig and BakeTarget come from your renderer package. defineConfig returns its argument. The loader is part of the bake CLI only, not of the library.
Errors
A config that bake cannot use is an error with the file, line and column of the problem (exit code 2):
| Config | Error |
|---|---|
targets: ['web', 'linux'] | bake.config.ts:4:5: targets[1]: "linux" is not a target; use web, ios, android, mac, windows |
targets: ['web', 'web'] | bake.config.ts:1:35: targets[1]: "web" is listed twice |
targets: [] | bake.config.ts:1:18: targets is empty; list the platforms the app ships on: … |
targets: 'web' | bake.config.ts:1:18: targets must be an array of web, ios, android, mac, windows, not "web" |
strictAot: false | bake.config.ts:1:36: "strictAot" is not read from bake.config.ts yet; keep it in package.json "bakenative": { "strictAot" } … |
tragets: [...] | bake.config.ts:1:18: unknown key "tragets"; bake.config.ts has: … |
android: { minSdk: 28 } | bake.config.ts:1:29: android.minSdk must be an API level from 29 (the BakeNative host's minimum) to 37, not 28 |
android: { minsdk: 31 } | bake.config.ts:1:29: unknown key "android.minsdk"; android has: minSdk |
| no default export | bake.config.ts: no default export; write export default defineConfig({ targets: [...] }) |
| a syntax error, a missing import | bake.config.ts: cannot load it: <the error> |
bake.config.ts and bake.config.mjs | two config files, bake.config.ts and bake.config.mjs: keep one (bake reads only one) |
package.json "bakenative"
The other app settings are still in package.json, under "bakenative":
| Field | What it sets | Read by |
|---|---|---|
strictAot | Turns strict AOT off with false (AOT fast-path check) | bake build, bake dev, bake aot, bake check |
package | The app package: name, id, version, modules, schema, requires, runtime, nativeBuild, thirdParty, android (Package an app) | bake package, bake build (ios), bake package check / host-check |
Writing either one in bake.config.ts is an error that names its place in package.json, rather than a setting that is silently ignored.