---
title: "Recipe: a Settings window"
description: "A link to a route whose shortcut is Meta+, is the app menu's Settings… (LLP 1030.004 D5)."
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.

# Recipe: a Settings window

<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/recipes/settings-window: <what was wrong or missing>"`

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

</AgentInstructions>

A `link` to a route whose shortcut is `Meta+,` is the app menu's Settings…
(LLP 1030.004 D5). On the Mac it opens the window named `settings` at that
route, as `target="settings"` would, without your writing `target`: the route
alone, no minimize or zoom, never a tab, its title the shown pane's heading,
its frame kept. It reopens at the pane last shown, and ⌘, brings it forward as
it stands. ⌘W closes it; Escape does not. On the web and other hosts the link
navigates in place, as any link does.

```prompt Add a Settings window
Give the Exact app in this folder a Settings window on the Mac, which the app menu's Settings item opens. Use https://github.com/expo/exact/blob/main/docs/recipes/settings-window.md as the source for each step. The Exact checkout has the same page at docs/recipes/settings-window.md.

1. If this folder is not an Exact app (it has no exact.mjs and app.contract), stop and tell me.
2. If I did not say which settings the window holds, and whether it has one pane or several, propose them and ask me before you write code. The window is the Mac's: on the web and other hosts the link navigates in place.
3. In app.contract, add a route for Settings in `routes`, and a `link` to it with `aria-keyshortcuts="Meta+,"` and an `aria-label`. That shortcut makes the link the app menu's Settings item. On the Mac it opens the window named `settings` at the route: write no `target`. An authored `target` wins, and `target="_self"` keeps Settings in the window it was chosen from.
4. Use a `link`, not a `button` with `press`: a command that runs an action is still the Settings item, but it runs its action and no window opens.
5. Draw the Settings screen under its route, with a heading (`role="heading" aria-level=1`): the window's title is the shown pane's heading. For several panes, give each pane a route under the Settings route (`/settings/:pane`) and a heading. A link to a pane with `target="settings"` from elsewhere navigates the open Settings window there.
6. Keep each setting in a state with `persist`. The windows share one store, so a choice made in Settings reaches `main` at once.
7. Add a test in app.test.contract that starts at the Settings route (`at "/settings"`), changes a setting, and expects the new value with `expect state`. End a test on each pane, so verify checks it.
8. Follow the platform checks in docs/start-here.md (`bun exact.mjs docs platform checks`) for the targets in the app's AGENTS.md and app.json until they pass. Read the reports, including counted findings; a zero exit code alone does not mean clean. Fix the app, not the test. On the Mac, also run `bun exact.mjs agent macos "type <testId> key Meta+," state` with the root's `testId`, and confirm that it lists the `settings` window rooted at the Settings route. If a finding stays after three rounds of fixes, or the app had it before you changed anything, record it (step 9) and report it; do not keep trying.
9. When a doc was wrong or missing, or a step needed a workaround, read `bun exact.mjs feedback status`. Under `never`, keep no note. Otherwise record it: `bun exact.mjs feedback note "<what happened>"`, which goes to Expo only as that status says. Do not change the policy; tell me how many notes you kept.
10. Tell me the settings and their panes, what the tests and checks reported, and what I can check by hand on the Mac: the window reopens at the pane last shown and keeps its frame, and Command-W closes it but Escape does not.
```

```contract
routes nav
  home "/"
    settings "/settings"

component App
  state units = "C" persist
  action follow(url: string)
    nav = go(nav, url)
  action unit(u: string)
    units = u
  view
    main testId="root" navigationKey=`${top(nav).id}` navigate=follow width="100%" height="100%"
      link href="/settings" aria-keyshortcuts="Meta+," aria-label="Settings" testId="open-settings"
        image "symbol:settings"
      for e in stack(nav) key=e.id
        if e.name == "home"
          column navigationKey=`${e.id}` position="absolute" inset=0 padding=16
            head title="Weather"
            text (units == "C" ? "21 °C" : "70 °F") testId="reading"
        if e.name == "settings"
          column navigationKey=`${e.id}` position="absolute" inset=0 padding=16 gap=12
            header display="flex" align-items="center"
              text "General" role="heading" aria-level=1 flex=1
            row role="radiogroup" aria-label="Temperature"
              button role="radio" aria-checked=(units == "C") press=unit("C") testId="unit-c" flex=1
                text "°C"
              button role="radio" aria-checked=(units == "F") press=unit("F") testId="unit-f" flex=1
                text "°F"
```

A choice made in Settings reaches `main` at once: the windows share one store.
Drive it with `bun exact.mjs agent macos "type root key Meta+," state`, which
lists the `settings` window rooted at `/settings`.
`session settings` sends the ops after it to that window:
`bun exact.mjs agent macos "type root key Meta+," "session settings" tree "screenshot settings.png window"`.

What to know:

- **An authored `target` wins.** `target="_self"` on the link keeps Settings in
  the window it was chosen from.
- **A command that runs an action** (`button press=… aria-keyshortcuts="Meta+,"`)
  is still Settings… and runs its action; no window opens.
- **Panes.** Give each pane a route under the Settings route
  (`/settings/:pane`) and a heading; a link to one with `target="settings"`
  from elsewhere navigates the open Settings window there.
