Deploy Your Server Anywhere — Same Code
Nitro — The Server Engine
Nitro is Nuxt's universal server runtime — the same source builds for Node, Cloudflare Workers, Vercel Edge, Netlify, Deno, and more.
What you'll learn
- Recognize the .output/ directory produced by nuxi build
- Switch deploy targets by setting the Nitro preset
- Know which features are portable versus preset-specific
Underneath Nuxt’s server pages and /api routes sits Nitro — a tiny, portable runtime built on
h3. Nitro is the reason the same code can run on AWS Lambda, Cloudflare Workers, and a plain
Node process.
What nuxi build Produces
Run npx nuxi build and you’ll get an .output/ directory:
.output/
public/ # static assets and prerendered pages
server/
index.mjs # the runtime entry
chunks/ # treeshaken handler code The shape of that folder depends on the preset. For Node, it’s a self-contained ESM bundle you can
run with node .output/server/index.mjs.
Switching Presets
Nitro auto-detects the target (Vercel, Netlify, etc.) based on env vars and file presence. Force it explicitly when you need to:
// nuxt.config.ts
export default defineNuxtConfig({
nitro: {
preset: 'cloudflare-pages',
},
}) Common presets:
node-server— long-running Node.vercel,vercel-edge— Vercel functions / edge.netlify,netlify-edge— Netlify functions / edge.cloudflare-pages,cloudflare-workers— Cloudflare.deno-deploy,bun— alternative runtimes.
Portable vs Preset-Specific
Portable across presets:
defineEventHandler, h3 helpers, fetch, Web standards.server/api,server/middleware,server/utils.
Preset-specific (with caveats):
- Node-only modules (
fs,path) — fine on Node, broken on edge runtimes. - Database drivers that need TCP sockets — won’t run on Workers without HTTP proxies (e.g. Neon, PlanetScale serverless).
Treeshaking
Nitro removes unused server code per preset. If a handler isn’t reachable from any route, it’s dropped from the bundle. This keeps cold starts fast on edge runtimes.
server/api Deep Dive →