---
title: "Navigation and documents"
description: "A root-file routes table declares paths and an implicit router state."
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.

# Navigation and documents

<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/learn/contract-for-humans/navigation-and-documents: <what was wrong or missing>"`

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

</AgentInstructions>

A root-file `routes` table declares paths and an implicit router state. Nested
rows declare parentage; the path strings remain absolute patterns.

```contract
routes nav
  tab home "/"
    item "/item/:id"
  notfound

component App
  derive current = top(nav)
  action showItem
    nav = push(nav, path("item", "42"))
  action back
    nav = back(nav)
  action followLink(url: string)
    nav = go(nav, url)
  view
    main navigationKey=`${current.id}` navigationBack="back" navigate=followLink width="100%" height="100%"
      for e in stack(nav) key=e.id
        column navigationKey=`${e.id}` position="absolute" inset=0 gap=8
          header
            if e.name == "item"
              button id="back" press=back testId=`back-${e.id}`
                text "Back"
            text e.name role="heading" aria-level=1 testId=`route-${e.id}`
          if e.name == "item"
            text e.params.id
          button press=showItem testId=`open-${e.id}`
            text "Open item"
```

A navigation stack is built this way: one row per entry of `stack(nav)`, keyed by
the entry's id, so a retained screen keeps its state. The root's `navigationKey`
names the top entry, and each row's `navigationKey` names its own; the host
presents the stack from them. `navigationBack` names the `id` of the back control.
Each row is a direct child of the root and fills it: a covered entry is hidden, not
removed, so one in the flow would still take its room. Tabs with a stack each are
laid out as [the tabs corpus](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/contract/corpus/tabs.contract) shows.
`navigate=` receives locations the host navigates to itself, such as link clicks
and browser history.

A row with `navigationPresentation="modal"` is a sheet on iOS; `navigationDetent`
sets its resting heights, space-separated: `large` (the default), `medium`, a
point height (`"300"`), a percentage of the sheet's tallest (`"45%"`, above 0%
and at most 100%; `"100%"` is `large`), or `fit-content`, the route's content
height, which follows the content as rows arrive or text wraps. A point height, a
percentage and `fit-content` stop at the sheet's tallest and leave out the bottom
safe area, which UIKit adds below; so under `viewport-fit="cover"` a route that
pads `env(safe-area-inset-bottom)` gets it twice. With one height the sheet does not
expand and shows no grabber; with several (`"300 large"`) it is dragged between
them, the first to start. UIKit takes them shortest to tallest, and a point height
and a share of the tallest cross on some screen (`"300 45%"` is 300 then 360 on an
800-point sheet, 300 then 270 on a 600-point one), so the heights before `large`
are of one kind, points or percentages (`medium` is half), each taller than the
one before, and `large` goes last; a literal that breaks this is refused. A point
height that a small screen's tallest reaches, with a taller detent after it, is
left out there, so `"900 large"` on a phone is `large` alone.
`fit-content` goes alone, as `"fit-content large"`, or last after ascending stops
below `large` (e.g. `"medium fit-content"`) as a content-height ceiling: stops at
or above the sheet's natural content height are omitted, so short content opens
fitted and taller content opens at the preceding stop and expands to fit its
content up to the available height.
It measures the route laid out on its own with its height left to its
content, as CSS's `fit-content` does, so nothing the sheet gives it counts:
rows do not shrink into it, and a percentage `height` or `flex-grow` takes
nothing from it. On iOS every viewport unit (`vw`, `vh`, `vmin`, `vmax` and their
`s`/`l`/`d` kin) is the window's in every sheet (`vmin` and `vmax` its
smaller and larger side), as CSS's `vh` is the viewport's and never a
dialog's, so `height: 50vh` is half the screen at any sheet height
and `min-height: 100vh` opens the sheet at its tallest. A scrolling route is
measured the same way; its rows can keep the default `flex-shrink: 1`. On a window
narrower than 840 pixels the web's sheet opens at the height iOS opens it at, its foot on
the window's, and stays there: it has no grabber and is not dragged between
heights. A route pushed inside it stays in it at that height, as in UIKit's
sheet. It is the tallest sheet in a window under 480 pixels tall (UIKit's compact
height), and on a touch screen while a text field in it has the focus, as UIKit
raises a sheet over the keyboard. A wider window shows the card it always does.
Android shows a modal route as Material's bottom sheet at these heights (`large`
the window below the status bar, `medium` half that; `fit-content` rests at
`medium`), dragged between them or down to dismiss, over a scrim
(`host/android/README.md`). macOS and desktop Linux ignore the detent
(LLP 1075.003 §9.11, LLP 1115.000 D4.8).

A sheet's width on an iPad is its route's `navigationSizing`. `automatic`, the
default, is the platform's own sheet, as UIKit and SwiftUI present one: a form
sheet, centred at a standard size, on iPadOS 18 and later, and a page sheet
before. `page` is a page sheet, the window's full width, for a sheet whose
content needs the room, as a camera's or an editor's does; `form` is a form
sheet on every version. On an iPhone and a closed iPhone Duo the three are the
same full-width sheet, and the other hosts' sheets have one size. It is read as
the sheet is presented.

A route pushed while a sheet is on top is shown inside that sheet, which keeps the
detents of the route that opened it, and Back returns to the route before it in
the sheet. iOS and macOS show it in the sheet's own navigation stack, the web and
Android lay it out in the sheet's box, and desktop Linux in the box the sheet's
own route was laid out in. On iOS and Android a drag down, or a tap behind a sheet
with `closedby="any"`, closes the sheet with what was pushed inside it. A route
pushed over a `fullscreen` route is a page of its own.

`path("item", value)` checks the route and encodes its parameters. Always build
locations with it: a template literal as a location is refused and a string
literal is checked against the table, but any other computed string is not
checked. Parameter values can be strings or numbers. Declared route parameter
fields are strings; absent fields for another route are the empty string.

`push`, `open`, `replace`, `go`, `select`, and `back` return a router value; assign
the result to `nav`. `select` selects a tab by name. `top`, `stack`, and `depth`
read the router; `params(nav, name)` lists one parameter across the stack, and
`searchParam(entry, name)` reads an entry's query. Pushing the same URL already on
top does not add a duplicate visit. The [router corpus](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/contract/corpus/routes.contract)
shows a full retained navigation stack and tab UI.

A `head` element declares document metadata: `title`, `description`, `canonical`,
`image`, `robots`, and `status` (a literal 404, 410 or 503). The innermost active
declaration wins field by field. The title updates the browser tab, the macOS
window and the iOS scene. On Windows, it sets the window caption and the
window's UI Automation name. An empty title clears both, and removing the title
restores the app name. On Android, it sets the activity title. An empty title
clears it, and removing the title restores the activity label. AOSP's desktop
caption displays the application label.
[AOSP window decoration source](https://android.googlesource.com/platform/frameworks/base.git/+/f4e211cf82c8c3bffa3afd671e66c95eafdd28ad/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java#780)

Use `scroll document` for document scrolling and ordinary `scroll` for an inner
scrollport. Both need a bound. A route the window shows alone also scrolls the
page with its own `scroll`, unmarked, where the route is its `header`, boxes
above the scroller and the scroller filling the rest; `document=false` keeps it
inner (LLP 1048.003 D4). Route rows can declare `render`, `activate`,
`paint` and `pages` policies for the site's build, rendering and client-side view.
Leave `activate` unsaid unless a page needs otherwise: a rendered page then
loads no script until the reader acts, when nothing on it needs the runtime sooner
(LLP 1048.007). Follow
[the document corpus](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/contract/corpus/document.contract) and
[the document tests](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/contract/cli/tests/it/document.rs) for accepted policy
values and serving behavior (LLP 1048.003). A compiled interface alone is not a deployed website.
