Part 18 / Topic 2 of 8
output: "standalone" — built and measured, not just configured
next.config.ts now sets output: "standalone" (the installed output.md reference's own documented option), alongside this harness's existing cacheComponents/partialPrefetching. Rebuilding:
$ npm run build
...(same route table as section 1 — output: "standalone" doesn't change what gets built, only what gets additionally copied)...
$ ls .next/standalone
app node_modules package.json server.js
$ du -sh .next/standalone
62M .next/standalone
62 MB versus the full project's 549 MB node_modules — the documented claim ("only the necessary files... including select files in node_modules") measured directly, not taken on faith. The docs are equally explicit that server.js does not copy public/ or .next/static by default (expecting a CDN to serve those instead); without that step, static assets 404:
$ cp -r public .next/standalone/ && cp -r .next/static .next/standalone/.next/
With both folders copied, the standalone server actually serves real pages:
$ SESSION_PASSWORD=<the real value from .env.local> PORT=3101 node .next/standalone/server.js
▲ Next.js 16.4.6
- Local: http://localhost:3101
✓ Ready in 0ms
[instrumentation] server instance starting - pid 65123, NEXT_RUNTIME=nodejs
$ curl -s -o /dev/null -w "home: %{http_code}\n" http://localhost:3101/
home: 200
$ curl -s -o /dev/null -w "quickcart: %{http_code}\n" http://localhost:3101/quickcart
quickcart: 200
(Why SESSION_PASSWORD=... had to be passed explicitly on this command line is section 4 — don't skip it, the server returns a real 500 for every route without it, confirmed below.)
Done here? The practice set for Part 18 — including the solutions — is on the part page.