---
title: "Recipe: guests, personas and password sessions"
description: "Use the complete mixed identity app for the schema, Contract, TypeScript and browser tests."
modificationDate: "2026-11-18"
---

> ## 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: guests, personas and password sessions

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

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

</AgentInstructions>

This recipe needs the Snapback client at `<exact2>/snapback4/`, which this
repository does not include. Its accompanying `snapback4/README.md`, where a
checkout has it, contains “A complete mixed identity app”: the schema, Contract,
TypeScript and browser tests. The guide's retest command runs it twice against
the selected Snapback version.

Bare `use identity` permits guests and password accounts. Call `guest()` before
reading; keep its session with `auth: {store, key, now}` and grant `secret.keep`
for that key. `authConfig()` is public `GET /auth/config`; it reports `guests`,
`password` and `development`. `use identity password` removes guests.

On the web that store is origin-readable. [Web sessions](https://exact.expo.dev/recipes/web-sessions.md)
describes server-set HttpOnly cookies; this bearer-session example does not
implement them.

During development the schema may also declare `use personas alice, bob`.
Start with `state persona = ""`, signed out, and offer an explicit persona choice.
A persona uses development headers. Password and guest sessions use stored bearer
credentials; await logout before switching accounts. Hide retained rows until the
current principal's resource answers. `serve` refuses persona headers, so remove
those controls for production. Use a distinct secret key for each backend origin.

`reload` resets a transient persona choice. An inherited test that expected
Alice after reload must now expect signed out, then choose Alice explicitly.
A password or guest session restores from the secret store instead. These
steps are part of the complete example's tested transition:

```prompt Add guests, personas or password sign-in
Add identity to the Exact app in this folder, on its Snapback backend: guests, development personas or password accounts. Use https://github.com/expo/exact/blob/main/docs/recipes/snapback-auth.md as the source for each step. The Exact checkout has the same page at docs/recipes/snapback-auth.md.

1. If this folder is not an Exact app (it has no exact.mjs and app.contract), or it is not wired to a Snapback backend, stop and tell me: wire it first with docs/recipes/snapback.md.
2. Ask me which identities the app allows: guests and password accounts (`use identity`), password accounts only (`use identity password`), and whether development uses personas (`use personas alice, bob`). Do not choose for me.
3. The Snapback client is not included in Exact. Where the checkout has it at snapback4/, its accompanying snapback4/README.md contains "A complete mixed identity app": the schema, Contract, TypeScript and tests. Use that example; if the client or guide is missing, stop and report what is missing.
4. For guests, call `guest()` before a read. Keep the session with `auth: {store, key, now}` and grant `secret.keep` for that key. Use a distinct secret key for each backend origin. On the web this is origin-readable storage: read docs/recipes/web-sessions.md for server-set HttpOnly cookies; the bearer-session example does not implement them.
5. For personas, start with `state persona = ""` (signed out) and an explicit persona choice. Await logout before a switch of accounts. Hide retained rows until the current principal's resource answers.
6. `serve` refuses persona headers: tell me the persona controls must go before production.
7. In app.test.contract, add the recipe's test, with `fresh` and `epoch now` at the top of the file. A test that expected a persona after `reload` now expects signed out, then chooses the persona again.
8. Start `snapback4 dev` on the backend's port, as `bun exact.mjs snapback` names it. 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 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 which identities the app allows, what you must remove for production, what the tests and checks reported, and the launch command for each target platform.
```

```contract-test
test "persona reload signs out; a password session restores"
  expect text "session" == "Signed out"
  tap "alice"
  clock data
  expect text "session" == "Signed in"
  reload
  clock data
  expect text "session" == "Signed out"
  expect tree missing "note-0"
  type "email" "alice@example.com"
  type "password" "correct horse battery staple"
  tap "signup"
  clock data
  expect text "session" == "Signed in"
  reload
  clock data
  expect text "session" == "Signed in"
  tap "logout"
  clock data
  reload
  clock data
  expect text "session" == "Signed out"
  expect tree missing "note-0"
```

Run that test against `dev` with `fresh` and `epoch now` at the file's top.
“A complete online password app” in that client's guide adds login and periodic
session refresh with Contract time.
