# Building and Deploying — Next.js

Source: https://www.skillbyai.com/en/nextjs/s-deploy

> next build, next start, and hosting options.

## Production builds and where to run them

`next build` compiles, type-checks and prerenders the app and prints the route table; `next start` runs the production server (Node.js). Deployment options include platforms with built-in Next.js support (Vercel and others), Node.js servers or containers (the `output: "standalone"` option creates a minimal server bundle for Docker), and fully static exports (`output: "export"`) for sites that need no server features. Features like Server Actions, Proxy and dynamic rendering need a server runtime.

## From laptop to production

Build and run production servers, handle environment variables safely, and review with a checklist.

![Three ideas: build and deploy, environment and security, checklist.](assets/figures/nextjs/section-8-map.svg) — Figure 8.1 — Deploy, secure and review.

## Building and starting the demo, run

I built the demo store with `next build` (Next.js 16.3.8), started it with `next start` and requested pages with curl; the output is copied from that run, trimmed to the relevant lines. The build compiled, ran TypeScript and generated 13 static pages before printing the route table; next start then served the app on the chosen port.

```bash
npx next build
npx next start -p 3917
```

Output:

```
✓ Compiled successfully in 3.2s
  Finished TypeScript in 440ms ...
✓ Generating static pages using 7 workers (13/13) in 330ms
...
ƒ Proxy (Middleware)
```

## Build in CI

Run next build in CI on every pull request; type errors and prerender failures then block merges instead of deployments.

**Quiz:** Which deployment option cannot support Server Actions?

- [x] A fully static export (output: "export")
- [ ] A Node.js server running next start
- [ ] A container built with output: "standalone"
- [ ] A platform with Next.js support

*Answer:* A fully static export (output: "export"). Server features need a server runtime.
