---
title: "Access hatches"
description: "An access hatch hands the app's native code the platform object Exact built for a node, at defined moments, so the app can do what only that object can."
modificationDate: "2026-11-30"
---

> ## Documentation index
> Fetch the complete documentation index at: https://exact.expo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Access hatches

<AgentInstructions>

## Submitting feedback

From the app's directory, read `bun exact.mjs feedback status`. Under `never`, keep no note.
Respect `EXACT_FEEDBACK=0` and do not change the policy.

Otherwise record specific, actionable feedback with:
`bun exact.mjs feedback note "Exact docs: https://exact.expo.dev/reference/developer/access-hatches: <what was wrong or missing>"`

The note goes to Expo only as that status allows. Include no secrets or personal data.

</AgentInstructions>

An access hatch hands the app's native code the platform object Exact built for
a node, at defined moments, so the app can do what only that object can: add a
gesture recognizer, set a navigation bar's look, draw into a view. It configures
what Exact made; it never replaces a route's authored tree. (LLP 1075.003,
1075.003.000, 1075.003.000.001; its §13 is the as-built record.)

A route's `header` or navigation root's `tablist` with `appearance="none"`
keeps its authored bar on iOS, including layout and type; a header button with
it keeps that button and its contents authored in place; the rest of the header
still projects. An authored Back replaces UIKit’s Back. Search and a header
tablist can opt out on their own element too. Tab/tabpanel navigation and retained stacks
remain intact. An opted-out root tablist also stays authored on the Mac and in wide
web windows instead of becoming a sidebar, and either stays the page's on Android
(the shared rule, `kernel/src/bars.rs`). On the Mac a header button with it keeps
the whole header painted: the window's bar shows a header whole or not at all.
See [tabs](https://exact.expo.dev/recipes/tabs.md).

```sh
bun scripts/exact.mjs hatch avatar <app>     # in an app `exact new` made: bun exact.mjs hatch avatar
bun scripts/exact.mjs hatch --app <app>      # the app scope; --window for the window's
```

Native view factories have their own roster in `app.json`. Each `modules` item is
a unique tag string or an object with `tag` and optional `hosts`. Omitting
`hosts` means every host. A list names one or more of `ios`, `tvos`, `macos`,
`web`, `linux`, `windows` and `android`. For example,
`{"tag":"compose-card","hosts":["android"]}` needs a factory in the Android
artifact. Place `compose-card` under `if page.platform == "android"`, with
`page` bound to `exactPage()`. Every host's build checks the use. Apple, Android
and web builds report missing factories for their host as release errors or
development warnings. A web factory table that needs the DOM at import time runs
in system WebKit on macOS or the browser installed by web setup on Linux and Windows.
The painted Linux and Windows hosts report native views as unavailable.

The hatch verb writes a stub for each target the app builds (Swift in
`modules/apple/`, the page module in `modules/web/`, Rust in
`modules/linux/`), adds the word to
`app.json` `hatches` with those platforms, and tells you the node to mark:

```
column hatch="avatar" data-tone=(busy ? "busy" : "idle")
```

`"hatches": ["avatar"]` means every platform the app builds; `"hatches":
{"avatar": ["ios", "web"]}` names the platforms whose module handles the word.
Elsewhere the node is shown and no hatch is called for it. A hatch reads state
only through the node's `data-*` words (declared in `app.json` `data`), and is
called again when one changes.

An action can read those same declared words with
`querySelectorAll("[data-tone~=\"busy\"]")`: it returns the own ids of
mounted, displayed, non-inert matches in tree order; covered routes and
unselected tabs are hidden; a split list answers alongside its detail where
the host presents it (the web at desktop widths). Closed popovers
and dialogs are hidden, and open ones answer. For an Inspect overlay,
`elementsFromPoint(x, y)` returns the own ids of the boxes under a viewport
point, front to back. Both are action snapshots; `frame(id)` gives each
returned node's box for an outline. Point reads skip inert subtrees and use
the presenter's placement and order for open top-layer content.
The front modal's native backdrop names its dialog or presented route where it accepts input,
below any later popover, without exposing the page or a lower modal.

| Scope | Swift (`ExactModule`) | Page module (`modules/web/index.js`) |
|---|---|---|
| A node marked `hatch="word"` | `element(_:)`, `elementEnded(_:)`; a frame or video's `elementConfiguration(_:_:)` | `element(e)`, `elementEnded(e)` |
| A route, a navigation stack, tabs (iOS; the web's elements) | `route`, `routeEnded`, `navigation`, `tabs`, `tabContainer` | `route`, `routeEnded`, `navigation`, `tabs` |
| The window toolbar (macOS) | `toolbar(_:)` | none |
| The app: its facts, by the web's names, and the root node's `data-*` words as `data` (each in `app.json` `data`, which `hatch --app` adds; Swift reads `data-booted` as `app.data[.booted]`) | `app(_:)`, `appEnded(_:)` | `app(a)`, `appEnded(a)` |
| The window the session presents into | `window(_:)`, `windowEnded(_:)` | `window(w)`, `windowEnded(w)` |

A navigation controller (`navigation`) and Exact's tab container (`tabs`) are
UIKit's, and their `delegate` slot is Exact's, as More's is (LLP 1075.003
§3.5). Give a delegate to `navigation.delegate` or `tabs.delegate`: Exact
passes each call on to it after its own handling (a tab's `shouldSelect` and a
transition's animator ask it first), and sends it straight the calls Exact does
not implement, such as an interaction controller or the supported orientations.
Exact keeps it until another or nil is given, or the container goes. A
`controller.delegate` written directly takes the slot from Exact, which then
hears none of the container's calls, and a development build journals it. An
app that needs the tab container's slot itself owns the container
(`tabContainer`).

An `iframe` marked `hatch="word"` hands `element.platform` its `WKWebView` on
macOS and iOS, or the `PDFView` of a local PDF it shows, after the arm set its
data store, preferences, delegates and content worlds; `changed` hands the new
one when the arm replaces it (a new `partition`, a PDF to HTML). The arm owns
`navigationDelegate`, `uiDelegate`, `pageZoom`, the appearance, the user
scripts of its content controller and a PDF view's `delegate`, and a
development build names one the hatch changed (LLP 1020.002 §9); a script
message handler a hatch adds is not detected. Before each web view is made,
`elementConfiguration(_:_:)` hands the `WKWebViewConfiguration`. The arm has
set its data store and content worlds, and the frame has its own new
`WKPreferences` with the arm's two settings. Set an `applicationNameForUserAgent`, content rule lists, URL scheme
handlers for the app's own schemes, or the frame's preferences; the data store
and the content controller must stay the arm's. Change only the configuration
there: the node may not be in the tree yet. A hatched frame's first web view
waits for the module to connect, so this call comes before the web view is
made. The web view then arrives at `built`; if `built` has no `platform` (as
on macOS or in an iOS list row), the `changed` after this call hands it.

A hatched `video` on Apple calls `elementConfiguration(_:_:)` synchronously
before each item, including a changed source or `load(id)`. It hands an
`NSMutableDictionary`: `url` is the resolved source `URL`; set `asset` to an
`AVURLAsset` for custom loading. The arm applies the authored playback and
rendition preferences to that asset's item. `element.platform` then hands the
`AVPlayer` at `built`, or `changed` for a deferred player. The arm owns the item,
playback and authored preferences; retain any resource-loader delegate yourself.
See [video loading](https://exact.expo.dev/learn/contract-for-agents/views-layout-and-interaction.md#sound-midi-and-media) for an example
and AirPlay/FairPlay limits. Android has no video player hook yet.

**Linux, Windows and Android paint their own pixels**, so there is no platform
object to hand over. A hatch there is Rust: one type that implements
`exact_painted::Hatches` in `modules/linux/*.rs` (or `modules/android/`,
`modules/windows/`), named once with `pub type ExactHatches = App;` and
included by the app's Linux crate (`contract::native::rust_hatch_entry` in its
`build.rs`, which the Rust-data apps here already call). Its handle carries the
node's box and words, the same acts, and two things in place of a view:
`element.overlay().draw(|c, w, h| …)`, a Canvas 2D recording that replaces the
last one whole, clipped to the node and painted over it; and
`context.observe(&element, |me, input, cx| …)`, the pointer and key input that
lands in the box, after Exact has handled it, to read only. It has the app and
window scopes, `context.frames` and `context.after`, and `diagnostics`. There
`changed` is also called when the node's size alone changes, and `ended` after
the commit that removed the node. An Android build is the same crate built for
Android; its words are the ones `app.json` gives `android`.

No hatch runs before first pixel. A node's end runs while its view is still
there, so take back there whatever the hatch added. On iOS a hatched node is a
view of its own and its list row is not reused unless the hatch sets
`element.reusable`; `logs` says what each word gives up. On the Mac a row that
leaves a virtualized list's window can be rebound to the item the list needs
next (LLP 1078): its hatched node hears `ended`, then `built` for the new item,
as a new node would.

**Into Contract only as a person could.** A handle acts on an authored node:
`click()`, `focus()`, `blur()`, and `input(text)`, which replaces a text
field's whole value without moving focus. Each is queued and runs after the
hatch returns. There is no dispatch and no state write.

**The frame clock.** `context.frames { frame in … }` (the web:
`exact.hatches.frames(frame => …)`) ticks once a frame after that frame's
tasks, and `context.after(ms) { … }` waits on the session clock. Under the
agent both run on the virtual display, so a drive repeats. They are for
behaviour, not for measuring the display. A view animated on the wall clock
(`UIView.animate`, a display link) is not on the agent's: `clock +N` leaves it
where it was, and only `clock +N real` lets it run, so a splash drawn from
`frames` or `after` is the one a drive can step past.

**The design's tokens** (LLP 1121 D12). A native view draws in the design's
colours by name: `ExactForma(view).color(.surfaceCard)` on Apple (the view a
module made, or one inside it; in the process, a view under any node, or
`ExactForma(session:)` for a screen of the host's own), a `UIColor` or
`NSColor` that resolves the scheme, contrast and elevation it is drawn in;
`ExactForma(view).color("surface.card")` on Android, a `Color` int resolved
for the view's scheme. Each reads its place's app tuple: a view under an
`-exact-mode` pin answers that mode. `observe { … }` runs after each batch that
moved what the place reads (a `setMode`, a pin above it, a live edit, the
scheme, the root font size), so re-apply a colour kept in a layer there. A
name the design lacks answers the fallback (`color(_:fallback:)`) and is
logged once. `bun exact.mjs forma gen swift .` writes the names
(`.exact/forma/forma.swift`, never committed), which a module's build
compiles in. `apps/forma-host` is the sample.

A GPU canvas reads the same design with `surface=board(color("surface.board"))`.
Its explicit token arguments follow its own place, including a scheme or mode
pinned on an ancestor. A change in the complete resolved inputs causes one
bind and frame request, including after an ancestor pin changes on its own or
a live design value edit. Apple system colours use the reported light or dark
palette for the session's current contrast and app tint, with the kernel's
fallback until a colour is reported. A changed palette rebinds affected
surfaces. A native view's own contrast override, elevation and local tint are
outside that palette.

**Whose window.** `window.window` is nil unless the embedder set
`session.hatchesOwnWindow`, and `app.application` unless it set
`session.hatchesOwnProcess`. The standalone iOS app sets both; the standalone
Mac app sets the first for each document's session.

**Make the hatch visible to the agent.**

| In hatch code | Where it shows |
|---|---|
| `diagnostics.log("…")` | `logs`, as `hatch element avatar: …` |
| `diagnostics.count("swipes")`, `publish("last", value)` | `state.hatches` |
| `diagnostics.measure("swipe.worst", ms:)`, `begin("swipe") … end()` | `perf hatches`, with Exact's own timing of every call |
| `element.owns(view: added, "what it is")`, `owns(recognizer:…)` | `tree`, under the node, beside what the host observes of it |
| `element.parts = [ExactPart(id: "seal", view: v, role: "button", label: "Verified")]` | `tree`; `tap avatar/seal` clicks it as a real pointer event |

Diagnostics are bounded and kept only in a development build. `EXACT_HATCHES=off`
(`?hatches=off` on a web page) runs a development build with no hatch
connected; the app must still work. If a run dies inside a hatch, the next
launch's `logs` say which one.
