Nuxt uses Nitro as its server engine, which compiles your app for any hosting platform. You build once, and Nitro adapts the output to the target: Node.js server, static files, serverless functions, or edge workers.
Two build commands
nuxt build produces a server that handles SSR, API routes, and dynamic rendering:
nuxt build
node .output/server/index.mjsnuxt generate pre-renders every page to static HTML:
nuxt generate
# deploy .output/public/ to any static hostPresets
Tell Nitro which platform you're targeting:
// nuxt.config.ts
export default defineNuxtConfig({
nitro: {
preset: 'vercel'
}
})Or set it at build time:
NITRO_PRESET=cloudflare-pages nuxt buildMost platforms are auto-detected, so you often don't need to set a preset at all.
Platform examples
Vercel
Zero config. Vercel detects Nuxt automatically:
npm i -g vercel
vercelSupports SSR, API routes, edge functions, and preview deployments out of the box.
Netlify
npm i -g netlify-cli
netlify deploy --prodGood for static-heavy sites. SSR runs as serverless functions.
Cloudflare Pages
NITRO_PRESET=cloudflare-pages nuxt buildUnlimited bandwidth on the free tier. Your app runs on Cloudflare's edge network, close to users worldwide. Some Node.js APIs are not available in Workers.
Node.js server (VPS, Docker)
nuxt build
PORT=3000 node .output/server/index.mjsFull control. Works on any server that runs Node.js.
Docker
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:20-alpine
WORKDIR /app
COPY --from=builder /app/.output .output
ENV PORT=3000
EXPOSE 3000
CMD ["node", ".output/server/index.mjs"]docker build -t my-app .
docker run -p 3000:3000 my-appChoosing a platform
| Need | Platform |
|---|---|
| Fastest setup, great DX | Vercel |
| Static site with built-in forms | Netlify |
| Best global performance, low cost at scale | Cloudflare Pages |
| Full control, existing infrastructure | Node.js on VPS or Docker |
Environment variables in production
Runtime config values come from environment variables:
// nuxt.config.ts
export default defineNuxtConfig({
runtimeConfig: {
secretKey: '', // server-only, reads NUXT_SECRET_KEY
public: {
apiBase: '' // client + server, reads NUXT_PUBLIC_API_BASE
}
}
})Set them in your platform's dashboard or .env file. Nuxt maps NUXT_ prefixed env vars to config keys automatically.
The .output directory
After building, everything lives in .output/:
.output/
├── server/
│ └── index.mjs ← the server entry point
├── public/
│ └── _nuxt/ ← client assets (JS, CSS)
└── nitro.json ← build metadataThis directory is self-contained. Copy it to any server and run it.