---
title: "Recipe: serving and hosting"
description: "bun exact.mjs web-build --out dist builds dist/; bun exact.mjs serve dist serves on 127.0.0.1:8765 (--port, else PORT) and rebuilds edits."
modificationDate: "2026-11-17"
---

> ## 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: serving and hosting

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

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

</AgentInstructions>

```prompt Host my website
Build the Exact website in this folder, serve it, and make it ready for its host, at the origin's root or below a path. Use https://github.com/expo/exact/blob/main/docs/recipes/website-hosting.md as the source for each step. The Exact checkout has the same page at docs/recipes/website-hosting.md.

1. If this folder is not an Exact app (it has no exact.mjs and app.contract), stop and tell me.
2. Ask me where the site runs: on Exact's own server or on a static host, and at the origin's root or below a path such as `/app/`. Ask me whether other sites share the origin. The upload to the host is mine to do: publish nothing without asking me.
3. Build with `bun exact.mjs web-build --out dist`, then serve with `bun exact.mjs serve dist`: it serves on 127.0.0.1:8765 (`--port`, else `PORT`) and rebuilds edits. For API pages, start `bun server.ts` or set `API_BASE_URL`.
4. For a path, set `"host": { "web": { "base": "/app/" } }` in app.json with my path, then rebuild. The base starts and ends with `/`. If the app has a Rust renderer, use `--render js`. The wasm target, the signed update store (`deploy` and baked plans), auth callbacks and the web/native dev loop require `/`: if the app needs one of them, stop and tell me.
5. Keep each route pattern and location app-relative: do not write the base in a route, in `path` or in `push`. A route named `/app/item` opens at `/app/app/item`. In `host.web.head`, use `./assets/` paths for bundled files, and absolute URLs for destinations outside the site.
6. For a static host, read its file and fallback rules in `serve --help`. List for me what to upload: `dist/` mounted at the base, the hidden `.exact/` assets too, and the generated `robots.txt` and `.well-known/` files at the origin root as well. On a shared origin, these merge with the existing policies: show me both and ask.
7. Build again, serve the build, and request the base chosen in step 2. For a non-root base, also check that the same path without its trailing slash redirects to the base, and that `/` returns 404. Then run `bun exact.mjs verify` until it passes. 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 the build and serve commands, the base, what verify reported, and what I must still do on the host. A native binary needs a rebuild when the base or the origin changes.
```

## Serving

`bun exact.mjs web-build --out dist` builds `dist/`; `bun exact.mjs serve dist`
serves on 127.0.0.1:8765 (`--port`, else `PORT`) and rebuilds edits.
`npm run build` and `npm start` are aliases.
For API pages, start `bun server.ts` or set `API_BASE_URL`. Static hosts follow
`serve --help`. Upload hidden `.exact/` assets too (Wrangler included); see
[web sign-in callbacks](https://exact.expo.dev/learn/contract-for-agents/data-requests-and-side-effects.md#web-sign-in-callback).

## Hosting below a path

Set `"host": { "web": { "base": "/app/" } }` in `app.json`, then rebuild.
The base defaults to `/` and starts and ends with `/`.
`bun exact.mjs serve dist` reads the base from the build and serves it at `/app/`.
On a static host, mount `dist/` there and apply its file and fallback rules.
Serve the generated `robots.txt` and `.well-known/` association files at the origin
root as well: crawlers, Apple and Android discover
them there. Merge them with existing policies on a shared origin. Exact's server
exposes these discovery files at the root; other requests outside
the mount return 404.
The server redirects `/app` to `/app/`, keeping its query; the client also normalizes
that root if a static host serves its shell directly.

Keep route patterns and locations app-relative: `book "/book/:id"`,
`path("book", id)`, `push(nav, "/add")` and a location passed through an action
parameter use the same paths as a root build. Entries and `navigate` events also
carry app-relative locations. The runtime removes the mount from incoming browser
locations and adds it to link hrefs and browser history. A route named `/app/item` opens at `/app/app/item`.
Destinations are canonicalized before mounting: `"item"` and `"/../item"`
both open `/app/item`. A data source's grant-free `fetch("/assets/file.txt")` reads
the bundled asset within the mount and the page's build generation. Images, video
posters and Markdown links follow the same boundaries. Canonical and social-image
paths receive the mount before they are made absolute against `app.origin`; explicit
absolute URLs are kept. `host.web.head` remains literal HTML: use `./assets/…` for
bundled files there, and absolute URLs for destinations outside the site.

The JS renderer supports build, request and cached pages under the base, including
install pages and the web manifest. An explicit manifest `scope` is mounted too;
without one, its scope is the directory of the mounted `start_url`. Use `--render js`
if the app has a Rust renderer. A one-off `render.mjs dist /item` and a driver's
`--url /item` also take app-relative locations.
Preferred native claims use the mounted scope, excluding mounted `/.exact/` where
supported. Links on `app.origin` lose the base at a segment boundary on cold and
warm delivery, keeping query and fragment. Reloads retain the mount; agent URL
navigation uses it too. Extension origins keep their paths. Rebuild binaries when
base or origin changes.
The wasm target, Rust renderer, signed update store (`deploy` and baked plans), auth
callbacks and web/native dev loop require `/`.
