Overview
The path from one .tsrx file to a native screen that appears before JavaScript runs.
Native apps built on a JavaScript runtime usually start the same way: launch the app, start the JS engine, run the bundle, render, create every view, and only then show something. Octapus moves most of that work out of the launch.
Three stages
1. Build
oct build compiles your app twice from the same source with Vite and Octane's compiler:
- For web, a normal browser build that renders to the DOM.
- For each native target, a single script that renders through Octane's universal renderer, compiled by
hermescinto Hermes bytecode (app.hbc). Branches onimport.meta.env.OCT_TARGETfor other platforms are removed.
2. Bake
With --bake, oct runs your bytecode once in Hermes, takes the first commit (the element tree your app renders on its first pass), resolves its CSS for light and dark mode, and writes the result as the first-screen snapshot (app.ofrm). The snapshot holds no positions or sizes, because those depend on the device.
3. Launch
When an Octapus view launches, two things happen at once:
- On the main thread, the snapshot is laid out for the view's real size with the device's own fonts and drawn as native views. No JavaScript is involved, so this takes a few milliseconds.
- On a JS thread, Hermes loads
app.hbcand renders your app's first commit.
When the hydration strategy says so, Octapus compares Hermes's first commit with the snapshot. If they describe the same tree, it hands the views already on screen to your app instead of creating new ones (adoption). From then on, your app updates those views like any other render.
time ─▶
main thread │ draw snapshot │ │ adopt (0 views created) │ interactive
JS thread │ start Hermes · run app.hbc · first render │Why it is fast
- Nothing to compute at first paint. Your CSS was resolved at build time, and drawing the snapshot is one forward pass over its rows.
- JavaScript is off the critical path. It runs in parallel with the first paint instead of before it.
- No second build of the screen. Adoption reuses the views that are already visible, so the takeover costs milliseconds and nothing flickers.
Why it looks like the web
Native screens are not a re-interpretation of your app with native widgets. Octapus computes CSS, layout, text and painting the way a browser does, in one engine shared by every Apple platform, and the platform views only display the result. See Rendering.