Nuxt Generate vs. Nuxt Build: Which Command Should You Use?
Nuxt generate creates prerendered static files; nuxt build creates the deployment artifact your configured runtime needs. Choose with this guide.
Short answer: In Nuxt 4, nuxt generate builds your application and prerenders routes with Nitro’s crawler, writing static HTML and payload assets to .output/public. Use it when your host only needs static files. Plain nuxt build creates an artifact for the Nitro deployment preset you selected; with the Node preset, that includes a runnable server entry point at .output/server/index.mjs. Use it when you need server or runtime behavior. nuxt build --prerender expresses the static-prerendering flow through the build command.
The practical difference is the deployment artifact and whether a server must run after the build. Read the output and route-coverage sections before choosing.
What each command does
| Command | Output | Use it when |
|---|---|---|
nuxt generate |
Prerendered HTML and payload assets in .output/public |
You deploy to static hosting, object storage or a CDN |
nuxt build |
Artifact for the configured Nitro preset | You need a Node, serverless or edge runtime |
nuxt build --prerender |
Static-prerendered output, equivalent in intent to generate | You want prerendering controlled through the build command |
Nuxt documents these deployment modes—Node, prerendered static hosting, serverless and edge—in its deployment guide. The prerendering guide describes nuxt generate as building and pre-rendering with the Nitro crawler.
How to run each command
1. Define package scripts
{
"scripts": {
"dev": "nuxt dev",
"build": "nuxt build",
"generate": "nuxt generate",
"preview": "nuxt preview"
}
}
2. Generate a static site
npm run generate
# or
npx nuxt generate
Deploy the contents of .output/public to your static host. The crawler starts from the root route, includes discoverable non-dynamic routes and follows links it finds.
3. Build a server deployment
npm run build
# Node preset example
node .output/server/index.mjs
The exact artifact depends on nitro.preset and your deployment target. Do not assume every preset produces the Node entry point above.
4. Prerender through build
npx nuxt build --prerender
Use this when your CI has one build command and you want that command to produce static output.
Choosing by deployment requirement
| Requirement | Recommended command | Reason |
|---|---|---|
| Static file service or CDN | nuxt generate or nuxt build --prerender |
All emitted pages are files; no application server is required |
| Server routes, authentication callbacks or request-time rendering | nuxt build with a server-capable preset |
Runtime code must execute after deployment |
| Serverless or edge provider | nuxt build with that provider’s Nitro preset |
The preset creates the provider-specific functions or bundles |
| Client-only SPA on static hosting | Set ssr: false, then use the documented static deployment flow |
The host serves an entry page and JavaScript bundles; SEO differs from prerendered HTML |
Route discovery and dynamic URLs
Generate is crawler-based, so a route that is not reachable from a discoverable page may not be emitted. This commonly affects product pages, documentation pages and routes whose IDs come only from an API.
Explicitly prerender important routes
// nuxt.config.ts
export default defineNuxtConfig({
nitro: {
prerender: {
routes: [
'/pricing',
'/docs/getting-started',
'/products/example'
],
// Add exclusions when a route must remain runtime-rendered.
ignore: ['/admin/**']
}
}
})
In Nuxt 4, use nitro.prerender for route lists and exclusions. The older top-level generate configuration option was removed; that configuration migration is separate from the nuxt generate command. See the Nuxt upgrade documentation.
Dynamic route checklist
- List every required dynamic path in
nitro.prerender.routes, or link to it from a crawled page. - Confirm API data is available during the build.
- Check the generated directory for each expected
.htmlfile or route payload. - Decide whether frequently changing content should stay server-rendered.
Fallback files and host routing
Static prerendering creates 200.html and 404.html fallbacks. Hosting platforms handle these files differently: some require a rewrite to 200.html, while others use their own single-page-app or error-document settings. Configure the host according to its routing rules and verify a deep link such as /docs/getting-started when loaded directly.
Runtime limitations of generated output
A generated site contains the result of rendering at build time. Server endpoints, request headers, per-request authentication and other runtime behavior are not included as a running server. If a page must react to each request, use nuxt build with an appropriate preset or split the site into static pages plus a runtime service.
Performance, reliability and cost considerations
- Build time: prerendering more routes increases build work because each route is rendered and its payload generated.
- Request latency: static files can be served directly by a CDN; server builds add a runtime hop but support request-time logic.
- Reliability: static hosting removes application-server failure modes after deployment, but a missed route or incorrect fallback becomes a content outage.
- Data freshness: generated pages remain unchanged until the next build. Runtime rendering reflects request-time data according to your server and cache configuration.
- Cost: choose based on your host’s bandwidth, build and runtime pricing. The Nuxt documentation does not provide universal performance or cost figures, so measure with your own routes and provider.
CI examples
Static artifact pipeline
# example CI steps
steps:
- run: npm ci
- run: npm run generate
- run: upload-artifact .output/public
Node deployment pipeline
steps:
- run: npm ci
- run: npm run build
- run: node .output/server/index.mjs
Replace the final upload or start step with the commands required by your hosting provider’s Nitro preset.
Troubleshooting
“The page works in dev but is missing after generate”
Cause: the crawler never discovered the route. Fix: add the URL to nitro.prerender.routes, link to it from a crawled page, and regenerate.
“A dynamic page contains no data”
Cause: the build cannot reach the API, or the data is only available in a request-time context. Fix: make build-time data available, fail the build when required data is absent, or render that route with a server preset.
“Server endpoints return 404 on static hosting”
Cause: .output/public contains files, not a running Nitro server. Fix: deploy with nuxt build and a server-capable preset, or host the endpoint separately.
“Deep links return the host’s 404 page”
Cause: host rewrites or fallback settings do not match Nuxt’s generated files. Fix: configure the provider’s rewrite/error document and test direct navigation to nested routes.
“The Node entry point does not exist”
Cause: you used a non-Node Nitro preset. Fix: follow that target’s deployment instructions; .output/server/index.mjs is specific to the Node server output.
“The old generate config is ignored”
Cause: Nuxt 4 removed the old top-level generate option. Fix: move route configuration to nitro.prerender.
Verify the deployed result with ScreenshotNeo
After deployment, visual checks catch missing routes, incorrect fallbacks and rendering differences that a build log cannot show. ScreenshotNeo is a website screenshot API and MCP server. It removes cookie banners, newsletter popups and chat widgets before capture; only clean shots are billed, while bot checks, blank pages, timeouts, failed loads and cache hits are not billed.
Or skip the browser setup
Use one request to capture the deployed Nuxt URL. See the ScreenshotNeo API documentation for all options.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://your-nuxt-site.example/docs/getting-started -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://your-nuxt-site.example/docs/getting-started"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://your-nuxt-site.example/docs/getting-started' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
ScreenshotNeo also provides an MCP server for Claude, Cursor and other MCP clients, plus full-page capture, custom waits, device presets, PDF output and signed webhooks. Free accounts include 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.
FAQ
Is nuxt generate deprecated?
The Nuxt 4 documentation describes it as the command for building and prerendering with Nitro’s crawler. Nuxt 3 reached end of life on 31 July 2026, so use Nuxt 4 documentation for new projects.
Can I use nuxt build for a static site?
Yes. Use nuxt build --prerender or configure a static deployment flow. Plain nuxt build follows the selected Nitro preset.
Does generate prerender every possible URL?
No. It crawls discoverable routes and configured routes. Explicitly list important URLs that cannot be reached through links.
Which command should a typical content site use?
Use nuxt generate when pages can be produced at build time and your host serves static files. Use nuxt build when requests need server logic or frequently changing data.
