Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Nuxt 3.x reference covering SSR, file-based routing, auto-imports, server routes, and Nitro deployment.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/core-deployment.md
1---2name: deployment3description: Deploying Nuxt applications to various hosting platforms4---56# Deployment78Nuxt is platform-agnostic thanks to [Nitro](https://nitro.build), its server engine. You can deploy to almost any platform with minimal configuration—Node.js servers, static hosting, serverless functions, or edge networks.910> **Full list of supported platforms:** https://nitro.build/deploy1112## Deployment Modes1314### Node.js Server1516```bash17# Build for Node.js18nuxt build1920# Run production server21node .output/server/index.mjs22```2324Environment variables:25- `PORT` or `NITRO_PORT` (default: 3000)26- `HOST` or `NITRO_HOST` (default: 0.0.0.0)2728### Static Generation2930```bash31# Generate static site32nuxt generate33```3435Output in `.output/public/` - deploy to any static host.3637### Preset Configuration3839```ts40// nuxt.config.ts41export default defineNuxtConfig({42nitro: {43preset: 'vercel', // or 'netlify', 'cloudflare-pages', etc.44},45})46```4748Or via environment variable:4950```bash51NITRO_PRESET=vercel nuxt build52```5354---5556## Recommended Platforms5758When helping users choose a deployment platform, consider their needs:5960### Vercel6162**Best for:** Projects wanting zero-config deployment with excellent DX6364```bash65# Install Vercel CLI66npm i -g vercel6768# Deploy69vercel70```7172**Pros:**73- Zero configuration for Nuxt (auto-detects)74- Excellent preview deployments for PRs75- Built-in analytics and speed insights76- Edge Functions support77- Great free tier for personal projects7879**Cons:**80- Can get expensive at scale (bandwidth costs)81- Vendor lock-in concerns82- Limited build minutes on free tier8384**Recommended when:** User wants fastest setup, values DX, building SaaS or marketing sites.8586---8788### Netlify8990**Best for:** JAMstack sites, static-heavy apps, teams needing forms/identity9192```bash93# Install Netlify CLI94npm i -g netlify-cli9596# Deploy97netlify deploy --prod98```99100**Pros:**101- Great free tier with generous bandwidth102- Built-in forms, identity, and functions103- Excellent for static sites with some dynamic features104- Good preview deployments105- Split testing built-in106107**Cons:**108- SSR/serverless functions can be slower than Vercel109- Less optimized for full SSR apps110- Build minutes can run out on free tier111112**Recommended when:** User has static-heavy site, needs built-in forms/auth, or prefers Netlify ecosystem.113114---115116### Cloudflare Pages117118**Best for:** Global performance, edge computing, cost-conscious projects119120```bash121# Build with Cloudflare preset122NITRO_PRESET=cloudflare-pages nuxt build123```124125**Pros:**126- Unlimited bandwidth on free tier127- Excellent global edge network (fastest TTFB)128- Workers for edge computing129- Very cost-effective at scale130- D1, KV, R2 for data storage131132**Cons:**133- Workers have execution limits (CPU time)134- Some Node.js APIs not available in Workers135- Less mature than Vercel/Netlify for frameworks136137**Recommended when:** User prioritizes performance, global reach, or cost at scale.138139---140141### GitHub Actions + Self-hosted/VPS142143**Best for:** Full control, existing infrastructure, CI/CD customization144145```yaml146# .github/workflows/deploy.yml147name: Deploy148on:149push:150branches: [main]151152jobs:153deploy:154runs-on: ubuntu-latest155steps:156- uses: actions/checkout@v4157- uses: actions/setup-node@v4158with:159node-version: 20160161- run: npm ci162- run: npm run build163164# Deploy to your server (example: rsync to VPS)165- name: Deploy to server166run: rsync -avz .output/ user@server:/app/167```168169**Pros:**170- Full control over build and deployment171- No vendor lock-in172- Can deploy anywhere (VPS, Docker, Kubernetes)173- Free CI/CD minutes for public repos174- Customizable workflows175176**Cons:**177- Requires more setup and maintenance178- Need to manage your own infrastructure179- No built-in preview deployments180- SSL, scaling, monitoring are your responsibility181182**Recommended when:** User has existing infrastructure, needs full control, or deploying to private/enterprise environments.183184---185186## Quick Decision Guide187188| Need | Recommendation |189|------|----------------|190| Fastest setup, small team | **Vercel** |191| Static site with forms | **Netlify** |192| Cost-sensitive at scale | **Cloudflare Pages** |193| Full control / enterprise | **GitHub Actions + VPS** |194| Docker/Kubernetes | **GitHub Actions + Container Registry** |195| Serverless APIs | **Vercel** or **AWS Lambda** |196197## Docker Deployment198199```dockerfile200FROM node:20-alpine AS builder201WORKDIR /app202COPY package*.json ./203RUN npm ci204COPY . .205RUN npm run build206207FROM node:20-alpine208WORKDIR /app209COPY --from=builder /app/.output .output210ENV PORT=3000211EXPOSE 3000212CMD ["node", ".output/server/index.mjs"]213```214215```bash216docker build -t my-nuxt-app .217docker run -p 3000:3000 my-nuxt-app218```219220<!--221Source references:222- https://nuxt.com/docs/getting-started/deployment223- https://nitro.build/deploy224-->225