Quick start
Build a small app for web, macOS and iOS, and see its first screen appear before JavaScript runs.
This walks through one app from source to a native screen. It assumes you finished Installation.
Write the app
Create a React project with a web target and both Apple targets:
bake create my-app --targets web,ios,mac
cd my-app
pnpm installIn src/App.tsx, export your root component as App or as the default export.
import { useState } from 'react';
import { Pressable, Text, View } from '@bake-native/react';
export function App() {
const [count, setCount] = useState(0);
return (
<View>
<Text>Count: {count}</Text>
<Pressable accessibilityRole="button" onPress={() => setCount(n => n + 1)}>
<Text>Add one</Text>
</Pressable>
</View>
);
}The screen uses the built-in views View, Text, and Pressable. Use a built-in view whenever one fits, and use supported HTML when you reuse web markup. Use built-in views first explains the choice.
For Octane, pass --renderer octane to bake create and write your root component in src/App.tsrx. Octane's View, Text, and Image come from @bake-native/octane. Writing an Octane app covers that syntax.
Build it
List the platforms the app ships on in bake.config.ts, next to package.json:
import { defineConfig } from '@bake-native/react';
export default defineConfig({
renderer: 'react',
targets: ['web', 'ios', 'mac'],
});Then build every one of them:
pnpm bake build --bakeWithout the file, name the targets on each command: pnpm bake build --target web,ios,mac --bake. With it, bake build and bake check cover every listed target, and a --target that is not listed is an error. pnpm bake check runs the same fail-closed checks without writing bundles. See Config.
dist/
web/ index.html + assets open it in a browser
ios/ app.hbc app.css app.baked manifest.json
mac/ app.hbc app.css app.baked manifest.jsonEach native folder is a bundle: your app as Hermes bytecode (app.hbc), its global CSS, the first-screen snapshot (app.baked, required for native React builds), and a manifest that ties them together. Copy the folder into your app as is.
Show it in a macOS app
Add dist/mac to your app target as a folder reference (so it keeps its name inside the app bundle), then:
import BakeNativeAppKit
import SwiftUI
struct ContentView: View {
let bundle = BakeNativeBundle(directory: Bundle.main.url(forResource: "mac", withExtension: nil)!)
var body: some View {
BakeNativeView(bundle: bundle)
.frame(minWidth: 480, minHeight: 360)
}
}Show it in an iOS app
Add dist/ios the same way and push a BakeNative screen from anywhere in your app:
import BakeNativeKit
let url = Bundle.main.url(forResource: "ios", withExtension: nil)!
let screen = BakeNativeViewController(bundle: BakeNativeBundle(directory: url))
navigationController?.pushViewController(screen, animated: true)In SwiftUI, use BakeNativeSurface(bundle:) instead. See Embed in an iOS app for the other options.
Check the launch
Each BakeNative view reports what happened at launch. Log it to see the snapshot at work:
func logLaunch(_ event: BakeNativeRoot.Event) {
if case .metrics(let m) = event, m.phase == .adopted {
print("interactive after \(m.frameToInteractiveMs) ms, \(m.viewsCreatedOnAdopt) views created")
}
}
// iOS
screen.bakeNativeView.onEvent = logLaunch
// macOS
BakeNativeView(bundle: bundle) { host in host.root.onEvent = logLaunch }adopted with 0 views created means the first screen came from the snapshot and Hermes took it over without rebuilding anything. Tap Add one and the count updates in the existing view.
Next
- Hand the next feature to an agent: Working with AI agents.
- Move an existing React screen using React Native migration.
- Why the first screen is instant: How it works.