Skip to content
These are temporary community docs. The official docs are in progress.Help improve them
Markless
Esc
↑↓navigate↵open⌘Jpreview
On this page

Build once, deploy to many hosts

Build your app into one folder, then pick where it runs with a Nitro preset.

Last page, you wrote pages, endpoints, and middleware. Now ship them.

The router builds on Nitro. Nitro has presets for many hosts. We built one app for a Node server and for Vercel, with no code change.

Pick a host. Then run the build.

Where can one build run?

Pick a host. Then press Run the build and look at the folder it writes.

Where the app will run
Your terminalTry it
Terminal

$ npm run build

Not run yet.

Your app's files
  1. pages/same for every host
  2. api/same for every host
  3. middleware/same for every host
  4. document.tsrxsame for every host
  5. vite.config.tssame for every host
What the build did
Files you changed for this host0
Output folder.output/
  1. Nothing yet. Press Run the build.

Simplified. We built one app from the full-stack starter both ways: as a Node server, the default, and for Vercel. We changed no file between the two builds. The output lists show the main entries only. Other hosts are untested.

Notice that your files stay the same. Only the output folder changes.

The default: a Node server

npm run build
PORT=3000 node .output/server/index.mjs

The build runs three steps: the browser build, the server build, then Nitro. By default, Nitro builds a Node server. The server reads the PORT variable.

To try the build on your machine, run npm run preview.

What is in .output/

Path What it holds
.output/server/index.mjs the server you start
.output/public/build/ the browser code, sent with cache-control: public, max-age=31536000, immutable
.output/markless/router/types/ the route types
.output/nitro.json Nitro build information

Other hosts with a preset

Nitro reads the preset from the NITRO_PRESET variable. This build writes output for Vercel:

NITRO_PRESET=vercel npm run build

The output goes to .vercel/output/, with static/ and functions/ folders. The Markless website deploys this way.

Nitro has presets for many other hosts. We tested only the default Node server and Vercel with Markless. Treat other presets as untested.

Next: Which options can you change in vite.config.ts? Configuration →

Was this page helpful?