Chapter 7 of 7

Build and deploy

Check the project, make a production build, run it, and choose where it lives.

On this page

Check and build

bun run check
bun run build
optz: types ok
optz: built 8 pages, 2 API routes, 3 islands, 1 actions, MCP 1 tool (islands, react), pre-rendered 10 in 441 ms

The build renders every static page, writes compressed copies next to each file, and bundles each island on its own. Everything lands in dist/.

Run it

bun run start

Open http://127.0.0.1:3001. This is the production server: static pages come from memory, /suggest renders per request, and the API answers under /api. Set PORT and HOST to override the config.

Choose where it runs

targetcommandgood for
A Bun serverbun run startEverything this app does, behind nginx or a platform proxy
One executablebun run build --compileCopying a single file to a server
An edge workerbun run build --target edgeRunning close to visitors
Static filesbunx optz exportAny static host, for pages that need no server
nginx in frontbunx optz nginxPrinting an nginx config generated from your app

Your reading list needs a server for /suggest and its Server Action, so a static export would leave those out. Use a Bun server, an executable or a worker for it.

Tip

The deployment guide walks through how this site runs in production: systemd units, a generated nginx config, deploys with rollback, and verified backups.

What you built

  1. Pages/booksA static page with a typed link
  2. Data/books/[slug]A page per book, built from paths
  3. IslandsRatingThe only JavaScript on a book page
  4. Forms/suggestA Server Action that works without JavaScript
  5. API/api/books/randomJSON with a typed client
The reading list, chapter by chapter

Keep going