---
title: "Recipe: a Snapback backend (shared server data)"
description: "For shared server data, exact new app --snapback writes a guestbook and wires its driver, generated operations and device."
modificationDate: "2026-11-15"
---

> ## 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 Snapback backend (shared server data)

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

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

</AgentInstructions>

This needs the Snapback client at `<exact2>/snapback4/`, absent from this
repository; in a checkout without it, `exact new --snapback`
and `bun exact.mjs snapback` refuse, naming the missing client.

For shared server data, `bun <exact2>/scripts/exact.mjs new app --snapback
[--port <n>]` from the backend’s directory writes a guestbook and wires its
driver, generated operations and device. The default port is 4400.
`bun exact.mjs snapback` wires an existing app. With an existing schema, the
untouched greeting becomes a typed query and mutation explorer with `--online`.
`snapback --port <n>` records an ignored local backend selection.
At bake, `.exact/backend-origin` overrides `app.ts`'s `origin` constant.
`EXACT_BACKEND_ORIGIN` or `test web --backend <url>` selects the origin at bake
time without editing authored source or tests. Plain-string grants move their
matching `net.fetch` line and a `net.websocket` line at the same host (`ws:` for
`http:`, `wss:` for `https:`). For grants keyed by origin, the selected origin
must have its own entry, except that a development build may take a loopback entry
for the same server at a LAN address; see [keyed grants](https://exact.expo.dev/reference/developer/generate-typescript-data-source-types.md#bake-and-deliver-a-typescript-module).
A native drive refuses a build baked for another backend than the one selected
(or `app.ts`'s literal `origin`); `--backend <url>` drives it. A build with a
literal `origin` and no backend record must be rebuilt.
Where a checkout has the Snapback client, its `snapback4/README.md` covers
password sign-in, stored sessions and refresh with Contract time in “Personas
and password accounts”. This repository includes neither client nor guide.
A server-only schema takes `--online`; `snapback` and `update` preserve it.
On a plain scaffold, `snapback --port <n>` adds the origin and fetch/storage
grants. A computed origin or grants declaration needs an explicit edit.
After upgrading Snapback4, run `bun exact.mjs snapback --rebuild`.
`bun exact.mjs update` also rebuilds a mounted device after updating Exact.
Custom mounts: add `--artifact-only` to rebuild without rewiring.
`app.json`'s `typescript.sources` are virtual import mounts: `./backend/api.ts`
resolves through `backend` to `../snapback/generated/api.ts`, and
`./snapback4/snapback.ts` resolves through `snapback4` to the selected adapter.
These directories need not exist inside the app. `snapback --rebuild`
prints the resolved mappings.
The device's embedded `snapback4.engine` section records its identity;
`assets/snapback4.wasm.json` is derived diagnostic output.
`snapback`, `contract build`, `test web` and `agent web` refuse a stale device;
web drives compare it with the running server before opening the page.

The backend selection `.exact/backend-origin` is a build input; a test-only `seed.json` does not
make the build stale. Tests against the backend: [testing against a Snapback backend](https://exact.expo.dev/recipes/snapback-tests.md); guests,
personas and password sessions: [guests, personas and password sessions](https://exact.expo.dev/recipes/snapback-auth.md).
```prompt Connect my app to a Snapback backend
Give the Exact app in this folder shared server data from a Snapback backend. Use https://github.com/expo/exact/blob/main/docs/recipes/snapback.md as the source for each step. The Exact checkout has the same page at docs/recipes/snapback.md.

1. Find the Exact checkout (the folder with scripts/exact.mjs); if you cannot find it, ask me where it is. Ask me where the Snapback backend is and which port its origin uses (the default is 4400), and whether the schema is server-only. Do not guess them.
2. If this folder is an Exact app (it has exact.mjs and app.contract), wire it: `bun exact.mjs snapback`. If it is not, ask me before you make one; then, from the backend's directory, run `bun <exact2>/scripts/exact.mjs new <name> --snapback`, with `--port <n>` if the port is not 4400. For a server-only schema, add `--online`.
3. Select another local backend with `bun exact.mjs snapback --port <n>`, `EXACT_BACKEND_ORIGIN` or `bun exact.mjs test web --backend <url>`, not by an edit to app.ts or to the tests. A computed origin or grants declaration needs an explicit edit: tell me before you make it.
4. Write the screens with the generated operations that `snapback` mounts. For password sign-in, guests or personas, use docs/recipes/snapback-auth.md and tell me first.
5. Start `snapback4 dev` on the origin's port, as `bun exact.mjs snapback` names it: `test web` never starts a backend. Write tests in app.test.contract as docs/recipes/snapback-tests.md says.
6. If a command refuses a stale device, or after Snapback4 was upgraded, run `bun exact.mjs snapback --rebuild`.
7. 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. If a finding stays after three rounds of fixes, or the app had it before you changed anything, record it (step 8) and report it; do not keep trying.
8. 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.
9. Tell me what you wired and the origin it uses, the command that starts the backend, what the tests and verify reported, and the launch command for each target platform.
```
