# Writing an Octane app (/docs/guides/writing-apps)

With `@bake-native/octane`, an app is an ordinary [Octane](https://octanejs.dev) app. Everything in the Octane docs about components, state, effects and context applies. This page covers native support for Octane markup and CSS. For React components, start with [React Native migration](/docs/guides/react-native).

## Project layout [#project-layout]

```text
my-app/
  src/
    App.tsrx      the root component (export App, or a default export)
    styles.css    optional global CSS, applied on every target
  package.json
```

You can split the app into as many `.tsrx` files as you like and import them from `App.tsrx`.

## Views [#views]

Build the screen from the built-in views in `@bake-native/octane` whenever one fits. Use `View`
for containers, `Text` for text, `Image` for images, and [`VirtualList`](/docs/guides/lists#octane-virtuallist)
for long lists. Octane has no built-in press target, so use `<button onClick>`.

```tsx title="src/App.tsrx"
import { useState } from 'octane';
import { Image, Text, View } from '@bake-native/octane';

export function App() @{
  const [likes, setLikes] = useState(0);
  <>
    <View class="card">
      <Image source="https://example.com/avatar.png" resizeMode="cover" alt="Avatar" class="avatar" />
      <Text class="name">{'Ada Lovelace'}</Text>
      <Text>{'Likes: ' + likes}</Text>
      <button onClick={() => setLikes(n => n + 1)}>{'Like'}</button>
    </View>
    <style>
      .card { display: flex; flex-direction: column; gap: 8px; padding: 16px; }
      .avatar { width: 48px; height: 48px; border-radius: 24px; }
      .name { font-weight: 600; }
    </style>
  </>
}
```

`View` and `Text` take `class`, `style`, `nativeID`, `testID`, `accessibilityLabel`, and children.
`Image` takes `source`, `resizeMode`, and `alt`, plus the same props without children. For an
event handler, a `ref`, or an element that has no built-in view, use the HTML element. Supported
HTML and CSS render on every native target, so you can also reuse existing web markup.
[Use built-in views first](/docs/concepts/overview#use-built-in-views-first) explains when to
choose each.

## Styling [#styling]

All of these work the same on web and native:

- **Global CSS** in `src/styles.css`, with class, type, descendant and child selectors.
- **Scoped `<style>` blocks** inside a component, which only reach that component.
- **The `style` prop** for one-off values.
- **Media queries** on width and on `prefers-color-scheme`, plus viewport units (`vw`, `vh`, `dvh`). Dark mode follows the system on native.
- **Custom properties** (`var(--accent)`).
- **`transform`, `transition` and `@keyframes`.** Transitions and keyframe animations of `opacity`, `transform` and `background-color` run on the host's compositor; `color`, the border colors, `outline-color`, `box-shadow` and `filter` animate too (the core samples them every frame and repaints, no layout). Transition names Chromium does not animate either (`display`, `fill`, `stroke`, custom properties, ...) are accepted and do nothing, so Tailwind's `transition`, `transition-colors` and `transition-all` build as they are. `height`, `translate`, `rotate` and `scale` animate as well. Animating another layout property (`width`, margins, padding, insets) is a build error (`css-transition-property`, `css-keyframes-property`): animate `transform` instead. `onAnimationStart` / `onAnimationEnd` / `onTransitionEnd` and the other animation and transition events reach the element at the injected clock (the element only, they do not bubble), so an exit animation can unmount its element on `animationend`.
- **`::before` and `::after`** with `content`. Other pseudo-elements (`::marker`, `::placeholder`, `::selection`, `::first-line`, ...) are a build error (`css-pseudo-element`), as is `::before` / `::after` content in a platform-drawn button (`css-pseudo-native-control`).

`@font-face` in the app's `.css` files is bundled and registered on native ([Fonts](#fonts)); a rule inside `@supports not (-bake-native: true)` is web only.

### System text size [#system-text-size]

On native, the user's text size setting (Dynamic Type on iOS, Font size on Android, Text size on
Windows; macOS has none for app content) works like a browser's default font size setting. It scales the default `16px`, so text
in `rem`, `em` and the size keywords (`small`, `large`, ...) grows with it, and so do boxes sized
in `rem` / `em`. Anything in `px` stays the same size. Pick per element:

```css
.body { font-size: 1rem; }        /* follows the setting */
.badge { font-size: 12px; }       /* fixed */
:root { font-size: min(1rem, 24px); }  /* follows it, up to 24px */
@media (min-width: 40em) { .row { flex-direction: row; } }  /* 40em grows with the setting too */
```

In a browser the same CSS follows the browser's font size setting. Right-to-left layout is not
implemented yet: `direction: rtl` (and `unicode-bidi` other than `normal`) fails the build.

BakeNative resolves CSS the way WebKit does, starting from the same browser default stylesheet, so an unstyled `h1` or `p` looks like it does in Safari. `calc()`, `min()`, `max()`, `clamp()`, `light-dark()`, `env(safe-area-inset-*)` and the usual units and color syntaxes work.

### Safe area [#safe-area]

`env(safe-area-inset-top)`, `-right`, `-bottom` and `-left` are the parts of the view a status bar, notch, home indicator or system bar covers, in CSS px, as in Safari and Chrome. Use them anywhere a length goes, also inside `calc()`, `min()` / `max()` / `clamp()` and custom properties, so a header can paint under the status bar and a bottom bar can clear the home indicator with the same CSS on the web and on native:

```css
.header { padding-top: env(safe-area-inset-top); }
.composer { padding-bottom: max(env(safe-area-inset-bottom), 12px); }
```

The insets are the view's, not the screen's: a view laid out inside the safe area (the default `BakeNativeViewController` starts the page below the status bar and above the home indicator) has nothing covering it and reads 0, and a view that extends under the bars reads how far they reach into it. On iOS, `BakeNativeView.Options(edgeToEdge: true)` draws the page under the status bar, the Dynamic Island, the home indicator and a landscape notch (Safari's `viewport-fit=cover`); a transparent native header does the same at the top. On macOS, a full-size content view with `automaticallyAdjustsContentInsets = false` reads the transparent title bar's height as `top`. The values follow rotation, split view, full screen and window size changes; the keyboard does not change them (the focused field is scrolled above it, and the layout viewport stays put, as in Safari). Where nothing covers the view (Windows, ordinary macOS windows, desktop browsers) every inset is 0. A fallback (`env(safe-area-inset-top, 20px)`) is accepted but never used, since every host provides the four insets. Other environment variables (`keyboard-inset-*`, `titlebar-area-*`, `viewport-segment-*`, `safe-area-max-inset-*`), and `env()` in an `@media` condition, are a build error (`css-env`). `env(keyboard-inset-*)` stays one: it belongs to the VirtualKeyboard API, which only Chromium ships and which reports the keyboard only after a page sets `navigator.virtualKeyboard.overlaysContent`; Safari has no equivalent, so the same CSS could not work on iOS and the web.

### Unsupported is a build error [#unsupported-is-a-build-error]

Native targets fail closed: anything the native engine would drop, ignore or approximate is a build error, never a silent difference from the web. That covers CSS (`display: table`, `:hover` on `::before` / `::after`, unknown properties and values), elements (`<table>`), attributes (`title`) and JavaScript globals (`document` beyond `document.activeElement`, `WebSocket`); the [support list](/docs/reference/support) has every one. Each error names the file and line, what is not supported and why, and what to use instead:

```text
src/App.tsrx:14:5: error: `display: table` is not supported on native targets: table layout is not implemented: it would lay out as blocks. Instead: display: grid (grid-template-columns for the columns) (css-display-table).
```

`bake build --json` lists the same findings with their ids under `targets.<target>.errors`. The [support list](/docs/reference/support) is generated from the data the build checks with.

Escape hatches for web-only code:

- **CSS**: wrap it in `@supports not (-bake-native: true) { ... }`. Browsers apply it; native skips it and does not check it. `@supports (-bake-native: true)` is the native-only counterpart.
- **Code and markup**: branch on `import.meta.env.BAKE_TARGET` (see [Platform branches](#platform-branches)). The branch for another target is removed before the check, including a template `@if (WEB) { ... }` on a constant.
- **One line**: `// bake-allow <id>` (in CSS `/* bake-allow <id> */`) on the reported line, or alone on the line above it, allows that finding. Say why next to it.

To type-check native code without the DOM, extend `@bake-native/core/tsconfig.native.json`. It replaces the DOM lib with `native-globals.d.ts` (generated from the same list), so `document` or `WebSocket` is a type error as well.

### Templates stay on the AOT fast path [#templates-stay-on-the-aot-fast-path]

The same rule applies to template shapes that would leave the compiler's [AOT fast path](/docs/concepts/architecture#the-aot-fast-path). Examples are a `@for` without a key, a class built from data, and a signal read during render. Strict AOT is the default, so each such site is a build error on every target. The error names the file, line, rule and rule number, and gives the fix. To keep one site, add `// bake-allow <rule> -- <reason>` (`{/* … */}` inside markup) on that line or alone on the line above. To turn strict AOT off for the whole app, pass `bake build --no-strict-aot` or set `"bakenative": { "strictAot": false }` in `package.json`. Findings are then warnings, and the report ends with `strict AOT is off`. The rules are in the [CLI reference](/docs/reference/cli#aot-fast-path-check).

## Layout and text [#layout-and-text]

Block, flex and grid layout follow browser behavior. Text wraps and aligns like inline text on the web: `line-height`, `text-align`, `letter-spacing` and underlines are supported, and nested inline elements (`<strong>`, `<a>`, `<span>`) render as part of the surrounding text. A block whose content is inline (text, inline elements, `inline-block` / `inline-flex` boxes, controls, `<br>`) lays it out in line boxes as Chromium does: inline-blocks and text share lines and wrap, mixed font sizes and `line-height` set the line height, `vertical-align` (baseline, sub, super, text-top, text-bottom, middle, top, bottom, lengths) and inline padding, borders, margins and backgrounds apply. An inline `<svg>` or `<img>` that is a block's only content also sits on a line box, as in Chromium: on the baseline, with the gap below it that the parent's font and `line-height` leave (use `display: block` or `vertical-align` to remove it). A block that mixes such inline content with block-level children (`css-inline-formatting`) and the other cases listed below are build errors.

### Fonts [#fonts]

Declare app fonts with `@font-face` in a `.css` file the app imports (`src/styles.css`), with the font file in the app:

```css
@font-face {
  font-family: "Brand";
  src: url(./fonts/Brand.woff2) format("woff2");
  font-weight: 100 900; /* a variable face */
}
.title { font-family: "Brand", system-ui; font-weight: 650; }
```

`bake build` copies each file into the bundle (`fonts/<name>-<hash>.<ext>`) and lists it in `manifest.json`. The host registers the fonts for your app only, before the first frame, so the first screen (the snapshot) already draws in them: there is no fallback flash. Faces are matched as in the browser (CSS Fonts 4): `font-weight`, `font-style` and `font-stretch` ranges, `unicode-range` segments, then the next family in the list, then system fallback. `font-display` is accepted and has no effect on native.

Supported on every target: `.ttf`, `.otf` and `.woff2` files in the app, `local()`, and the descriptors `font-family`, `src`, `font-weight`, `font-style`, `font-stretch`, `unicode-range`, `font-display`. Android reads `.ttf` / `.otf` files only: WOFF2 and `local()` are build errors there (`css-font-face-format`). Remote URLs, other formats, other descriptors, a missing file, `@font-face` inside a component `<style>` and `@font-face` in a stylesheet loaded with a CSS `@import` (`css-font-face-import`: the bundler would inline the font as a `data:` URL; import that stylesheet from JS instead) are build errors. The fonts are never installed for the device or other apps: a face is visible only to the `font-family` lists of your app.

#### Bundled fonts [#bundled-fonts]

Select the bundled Geist faces or your own font files in [`bake.config.ts`](/docs/reference/config#fonts). Once configured, use their family names in CSS:

```css
body { font-family: "Geist", system-ui, sans-serif; }
code { font-family: "Geist Mono", ui-monospace, monospace; }
```

## Controls [#controls]

BakeNative loads a small control stylesheet before your CSS on every target, the browser included. It gives buttons and fields a plain background, border and padding, so by default a button looks the same in Safari, on macOS and on iOS. Your CSS overrides it as usual (its rules weigh what a bare `button` or `input` selector does).

To use the platform's own control instead, add `class="native"`:

```tsx
<button class="native" onClick={save}>Save</button>
<input class="native" type="search" placeholder="Search" />
```

| | Browser | macOS | iOS |
| --- | --- | --- | --- |
| `<button class="native">` | The browser's button | `NSButton` (push) | `UIButton`: Liquid Glass on iOS 26, gray before |
| `<input class="native">` | The browser's field | `NSTextField` | `UITextField` (rounded rect) |

A native control takes the platform's size, font and chrome, so it follows the OS when its design changes. On native, CSS `padding`, `border` and `font` do not apply to it. It stays native only while you leave its box alone:

- Painting a `background`, `border` or `border-radius` on it, or setting `appearance: none`, hands the box back to you. It is drawn exactly as styled.
- A button with anything but text inside (an icon `<span>` or `<svg>`) is drawn, because the platform button shows a title only.
- A `textarea`'s box is drawn from CSS like a field's, with the platform's multi-line editor inside (below). Check boxes, ranges, selects and the other form controls below are the system's own by default.

`disabled` works either way: the control looks disabled where the platform draws it, and sends no `click`, `input` or `change` events.

Text fields follow their HTML attributes on native. On iOS, `type` (`password`, `email`, `url`, `tel`, `number`, `search`), `inputmode`, `enterkeyhint`, `autocapitalize`, `autocorrect` / `spellcheck` and `autocomplete` (AutoFill, such as `one-time-code` or `new-password`) pick the keyboard, the Return key and secure entry. `maxlength`, `disabled` and `type="password"` (secure entry) work on iOS and macOS.

A `<textarea>` is a native multi-line editor (`UITextView` / `NSTextView`), `cols` characters wide and `rows` lines tall unless CSS sizes it. It fires `input` on every edit and `change` when editing ends. On iOS, Android and Windows (the touch keyboard) the page scrolls the focused field above the on-screen keyboard: the part of the view the keyboard covers becomes extra scroll room at the bottom of the page. As in Safari and Chrome, the keyboard does not change the layout viewport or `vh`.

### Form controls [#form-controls]

Form controls keep their platform look, as they do in a browser: Safari draws its own control on the web, and iOS and macOS draw the SwiftUI control.

| Element | SwiftUI control on iOS and macOS |
| --- | --- |
| `<input type="checkbox" switch>` | `Toggle` (switch) |
| `<input type="checkbox">` | `Toggle` (checkbox on macOS; a circled checkmark on iOS) |
| `<input type="range" min max step>` | `Slider` |
| `<select>` with `<option>`s (and `<optgroup>`s) | `Picker` with the menu style |
| `<progress value max>` | `ProgressView` (linear) |
| `<progress>` without `value` | `ProgressView` (spinner) |
| `<meter value min max>` | `Gauge` (linear capacity) |
| `<input type="date">`, `"time"`, `"datetime-local"` | `DatePicker` |
| `<input type="color">` | `ColorPicker` |

```tsx
<main style={{ 'accent-color': '#ff415a' }}>
  <input type="checkbox" switch checked={on} onChange={(e) => setOn(e.target.checked)} />
  <input type="range" min="0" max="100" value={volume} onInput={(e) => setVolume(Number(e.target.value))} />
  <select value={theme} onChange={(e) => setTheme(e.target.value)}>
    <option value="light">Light</option>
    <option value="dark">Dark</option>
  </select>
</main>
```

- **Tint** with CSS `accent-color`; it inherits, so set it once on a container.
- **Size** comes from the control itself, the way the platform draws it. CSS `width` and `height` override it, and a range or progress bar usually gets `width: 100%`.
- **Values** follow HTML: `checked`, `value`, `min`, `max`, `step`, `disabled` and `aria-label` work as on the web, and `e.target.value` is a string (`"50"`, `"2026-12-24"`, `"09:30"`, `"#ff415a"`).
- **Opt out** with `appearance: none`: the element becomes a plain CSS box that you style yourself.
- The first screen draws controls with the right state before JavaScript runs, and your app takes them over like any other view.

### Disclosure [#disclosure]

`<details>` and `<summary>` work as in browsers: a closed details shows only its summary, and tapping the summary opens or closes it and fires `toggle`. Leave `open` to the element, or control it with the `open` prop and `onToggle`. No disclosure marker is drawn on any target (native has no `::marker`); add your own, for example with `details[open] > summary` rules.

### Sheets [#sheets]

An open `<dialog>` is a bottom sheet. iOS and macOS present it as a SwiftUI sheet sized to its content (the platform draws the sheet and its grabber; the dialog's children are your HTML and CSS). The browser shows the same dialog pinned to the bottom of the viewport.

```tsx
const [open, setOpen] = useState(false);

<button onClick={() => setOpen(true)}>Share</button>
<dialog open={open} onClose={() => setOpen(false)}>
  <h3>Share</h3>
  <button onClick={() => setOpen(false)}>Done</button>
</dialog>
```

- **Open and close** it with the `open` prop. When the user swipes the sheet down (or presses Escape on macOS), the dialog fires `close`: set `open` back to `false` there.
- **Height** follows the content, like `fit-content`. The sheet's width is the platform's (the screen on iPhone, a readable column on macOS).
- The dialog's own background and border are replaced by the sheet's; style its children as usual.

Inline `<svg>` is drawn from its markup (paths, shapes, fills, strokes, `<defs>` / `<use>` / `<symbol>`, linear and radial gradients, `<clipPath>`, `<mask>` and `<text>`), with `currentColor`, CSS variables and the rules of the component's `<style>` that match its elements (`class`, `id` and type selectors). On Windows the shared rasterizer (`bake-svg`, a port of Chromium's Skia) draws it with Chrome's pixels; iOS and macOS draw the same shapes with CoreGraphics and Android with `Canvas`. Filters, patterns, markers and `<image>` are build errors. For tab bars, navigation bars, sheets and other SwiftUI views, see [SwiftUI components](/docs/guides/swift-ui).

## Events and timers [#events-and-timers]

| Event | Fires when |
| --- | --- |
| `onClick` | A button or any element with a click handler is tapped or clicked |
| `onInput` | The text in a field changes, a slider moves, or a control's value changes |
| `onChange` | The user commits a field (presses Return), releases a slider, or changes a switch, checkbox, select, date or color |
| `onSubmit` | The user presses Return in a field |
| `onClose` | The user dismisses a dialog's sheet |
| `onToggle` | A `<details>` opens or closes from its summary |

`setTimeout`, `setInterval` and their `clear*` functions work on native; the host schedules them.

## Element APIs [#element-apis]

A `ref` on a native element is an element handle with the DOM's names, so code written for the web's elements runs on native unchanged (on the web the ref is the DOM element itself). Everything below is synchronous on the JS thread: the Rust core's layout lives on that thread, so nothing waits for the UI thread.

```tsx
import { useLayoutEffect, useRef } from 'octane';

export function Popover(props) @{
  const panel = useRef(null);
  useLayoutEffect(() => {
    const anchor = props.anchor.current.getBoundingClientRect();
    const fits = anchor.bottom + panel.current.offsetHeight <= props.screen.current.clientHeight;
    panel.current.focus();
    // ... place the panel; it is positioned before its first frame
  });
  <div ref={panel} tabIndex={-1} class="panel">{props.children}</div>
}
```

| API | What it reads or does | Cost (2,401 nodes, release, M-series Mac) |
| --- | --- | --- |
| `getBoundingClientRect()`, `getClientRects()` | The border box in viewport coordinates, through 2D CSS transforms, minus scroll offsets | One JSI call (the core's part: 0.06 µs). The first read of a JS call lays out: 12 µs with nothing changed, ~0.4 ms after a class change, most of which the commit then saves |
| `offsetLeft` / `Top` / `Width` / `Height`, `offsetParent` | Relative to the nearest positioned or transformed ancestor, rounded | as above |
| `clientLeft` / `Top` / `Width` / `Height` | The padding box, rounded | as above |
| `scrollLeft` / `Top` / `Width` / `Height` | The offset the host last reported; the content size | as above |
| `focus()`, `blur()`, `document.activeElement`, `contains()` | The core's focus, which the host's keyboard and accessibility focus follow | `focus()` lays out like a read (a just-mounted element needs its box); the others do not |
| `addEventListener` / `removeEventListener` | Pointer, mouse, key, focus, wheel and animation / transition events on the element's path; `capture` and `once` | none |
| `getComputedStyle(el)` | `display`, `position`, `visibility`, `opacity`, `overflow*`, `pointerEvents`, `zIndex`, `transform`, `animation*`, `transition*`, `width`, `height`, `boxSizing`, `direction`, border widths, paddings | a property read |
| `inert`, `autoFocus` | An inert subtree takes no focus, no Tab stop, no taps and leaves the accessibility tree; `autoFocus` focuses a control when it mounts | |

Native element handles expose `scrollTop` and `scrollLeft` as read-only offsets.
`bake build` reports writes to those offsets through a JSX ref or its constant alias.
Keep a browser-only scroll assignment inside a branch on `import.meta.env.BAKE_TARGET`.

`bake build` includes the handles' code (about 8 KB of bytecode) only in bundles that name one of these APIs as a member (`ref.current.focus()`, `el.offsetHeight`), or `getComputedStyle` / `document.activeElement`; reaching them only through computed names (`el['focus']`) is not seen.

Reads apply what JS changed earlier in the same call first, as the web's forced layout does: set state in a layout effect, read the new layout, and the frame goes out once afterwards. Values match Chromium (the core's tests compare them with Chromium for boxes, transforms, scrolling, sticky and fixed boxes, fractional sizes and computed style strings).

Where native differs from the web:

- **No layout before the first commit.** The first render runs while the bundle evaluates, before the first screen reaches the core. Geometry and focus can throw `E_NO_LAYOUT` until the first commit reaches the core. The build-time bake has no layout and skips ref callbacks and effects. Read them in handlers and in effects of components that mount later (a dialog, a popover); a first-screen component that must measure on mount defers it with `requestAnimationFrame`.
- **Modal dialogs move the focus themselves.** An open `<dialog>` sheet, or a `role="dialog"` /
  `role="alertdialog"` with `aria-modal="true"`, is a modal scope: when one appears the focus moves
  to its first `autoFocus` element, else the first element of its Tab order; Tab stays inside the
  topmost one; when it closes (unmounts or is hidden) the focus returns to the element focused
  before it opened. For `<dialog>` this is what the browser does. For an ARIA modal the browser
  does nothing and a focus scope in JS does it (Radix's `FocusScope`), so on the web keep that code;
  on native it agrees with the core, which has already moved the focus.
- **Focus events after the call.** `focus()` moves focus at once (`document.activeElement` is the new element), but `focus` / `blur` / `focusin` / `focusout` run after the current handler or effect returns, not inside `focus()`.
- **Fail closed.** `getComputedStyle(el).<property>` outside the list is a build error when the build can see the name (`element-computed-style`); otherwise a property outside the list, an event `addEventListener` cannot deliver (use the JSX prop) and an element inside a native sheet (the host places it) throw `E_UNSUPPORTED`. `document` has only `activeElement`; other `document` and `window` members stay build errors.
- **Inline elements in text.** A `<span>` or `<a>` drawn as part of its paragraph's text has no box of its own in the core yet: its geometry throws `E_UNSUPPORTED` (measure the paragraph, or make the element `inline-block`).
- **Animated values.** `transform` and the rect are the computed values, not the values of a running animation. `animationcancel` listeners are accepted but never called.
- **Libraries.** `@floating-ui/core` runs unchanged with a platform made of these handles (`examples/element-api`). `@floating-ui/dom` and `@radix-ui/react-presence` do not build for native yet: they test for `window`, `Node`, `Element`, `HTMLElement`, `ShadowRoot` and `CSS`, and Presence writes `element.style` and needs React.

## Props, host events and native code [#props-host-events-and-native-code]

The host app passes props to your root component and sends it events (`host.on`); JS calls native code through typed native modules the screen registers:

```tsx
import { useEffect } from 'octane';
import { native, host } from '@bake-native/octane';

export function App(props) @{
  useEffect(() => host.on('deeplink', (url) => console.log(url)));

  <button onClick={() => native.Haptics.impact('light')}>{'Hello ' + props.user}</button>
}
```

See [Native modules](/docs/guides/native-modules) for defining modules, generated types, props and events. Call native functions from effects and handlers, not during render: the build-time bake has no native modules.

## Platform branches [#platform-branches]

`bake build` defines the target at compile time:

```tsx
import { Text } from '@bake-native/octane';

const isWeb = import.meta.env.BAKE_TARGET === 'web'; // 'web' | 'ios' | 'android' | 'mac' | 'windows'

export function Badge() @{
  <Text>{isWeb ? 'Running in your browser' : 'Running natively'}</Text>
}
```

Each native target is built separately, so code for other platforms is removed from the bundle.

## Networking [#networking]

`fetch`, `Request`, `Response`, `Headers`, `AbortController` / `AbortSignal` (with `AbortSignal.timeout` and `AbortSignal.any`), `URL`, `URLSearchParams` and `Blob` are the same on every native target, so the code you write for the web runs unchanged:

```ts
const res = await fetch('https://api.example.com/items', { signal: AbortSignal.timeout(5000) });
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const items = await res.json();
```

- Errors are the web's: a network error rejects with `TypeError`, an abort with the signal's reason (a `DOMException` named `AbortError`), a timeout with a `DOMException` named `TimeoutError`.
- Answers arrive on the JS thread; the UI thread never waits for the network. Windows sends requests through WinHTTP, iOS and macOS through `URLSession` (an ephemeral session: cookies in memory, no HTTP cache, the system proxy), Android through `HttpURLConnection` (cookies in memory, no HTTP cache, the system proxy and per-app VPN, the system trust store and the app's Network Security Config, including certificate pinning).
- On Android, `http://` URLs follow the app's [Network Security Config](https://developer.android.com/privacy-and-security/security-config): cleartext is off by default (API 28+), so such a request fails with a `TypeError` ("CLEARTEXT communication … not permitted"). Use `https://`, or allow cleartext for the hosts you need in the app's `res/xml/network_security_config.xml` (`<domain-config cleartextTrafficPermitted="true">`), referenced from `<application android:networkSecurityConfig>`; keep it to a debug source set when it is only for a local server (the emulator reaches the machine's loopback as `10.0.2.2`). The BakeNative library declares the `INTERNET` permission.
- Bodies: strings, `URLSearchParams`, `Blob`, `ArrayBuffer` and typed arrays in; `text()`, `json()`, `arrayBuffer()`, `bytes()` and `blob()` out. The whole body is read before `text()` resolves (no `response.body` stream).
- There is no page origin: URLs must be absolute (`fetch('/api')` is a `TypeError`, as an invalid URL is on the web), there is no CORS, and `credentials` is ignored. Redirects are followed; `redirect: 'error'` is honored and `'manual'` is a `TypeError`. Cookies live in memory for the process.
- Tests mock the network with `net` routes on the root's inspect channel (fulfill, abort, pass through), with delays on the root's clock. Under a driven clock an unrouted request fails, so a test never depends on the network. See the runtime's schema README, "Network".

## Not available on native yet [#not-available-on-native-yet]

- **DOM APIs.** There is no `window`, and `document` has only `activeElement` ([Element APIs](#element-apis) cover refs). Other DOM code must sit behind an `BAKE_TARGET` check.
- **WebSocket and streams.** `fetch` works on native (see [Networking](#networking)), but `WebSocket`, `EventSource`, `XMLHttpRequest`, `FormData` and `ReadableStream` bodies do not yet.
- **Links.** `<a href>` does not navigate on native. Open URLs from `onClick` through a native module.

Each of these is a build error on native targets.

## Support list [#support-list]

Every supported CSS property and value, element, attribute, event handler and JavaScript global, and where iOS, macOS, Android and Windows differ, is on the [support list](/docs/reference/support). It is generated from the allow lists the build checks with, so it is always what `bake build` accepts.

## Keep the first render deterministic [#keep-the-first-render-deterministic]

Your app's first render becomes the [first-screen snapshot](/docs/concepts/snapshot). It runs once at build time, with no props and no native modules, and again on the device, and the two results must match for the device to take over the snapshot. Avoid reading anything that changes between those two runs before the first render finishes, including props and native calls:

```tsx
import { useEffect, useState } from 'octane';
import { Text } from '@bake-native/octane';

export function Clock() @{
  // ✗ differs between the bake and the device:
  // const [now] = useState(Date.now());

  // ✓ render a stable placeholder, fill it in after the first commit
  const [now, setNow] = useState(null);
  useEffect(() => setNow(Date.now()));

  <Text>{now === null ? 'Loading…' : new Date(now).toLocaleTimeString()}</Text>
}
```

Give root props parameter defaults for the first render. For time or native state, render an
initial value and read the device value in an effect. For asynchronous data, use an Octane
`@pending` branch that renders in both the bake and the device's first commit.

When a requested bake fails, fix the reported render error or missing first commit before shipping
the target. A separate case can occur at launch when a valid snapshot and the device's first
commit differ. BakeNative mounts the device's commit and records the first differing row.
See [Troubleshooting](/docs/guides/troubleshooting).