Question presented to candidate: "A new teammate asks why the app is fast after deployment but the first page load on their laptop takes seconds, and why their change does not show up on the staging server until someone rebuilds. Explain what next dev, next build and next start each do."
What a strong answer should cover:
next dev: a development server that compiles routes on demand with Turbopack, hot-reloads changes, shows detailed errors, setsNODE_ENV=development, sendsCache-Control: no-storeand writes to.next/dev.next build: compiles and minifies for production, runs TypeScript checking, prerenders static routes, and prints a route table with symbols (static, SSG, partial prerender, dynamic).next start: a production Node.js server that serves the existing.nextbuild; it does not compile, so code changes need a new build, and it fails if no build exists.- Static pages built ahead of time are served from the prerendered output (with cache headers), dynamic ones are rendered per request.
- Practical details: default port 3000,
-p/PORT,--webpack,next buildandnext devcan run side by side because dev uses.next/dev.
Clarifying questions expected:
- "How is the app deployed: a Node server, a container, static hosting or a platform?" β
next startonly applies to a Node server. - "Is the slow page static or dynamic in the build output?" β that tells you what production does with it.
Code / implementation expected: Optional β the commands and a page showing the mode.