DEV Community

Discussion on: Next.js + Docker. Made easy.

Collapse
 
hirokihokari profile image
hirokihokari

Is next build necessary if you're doing next dev?

Collapse
 
maxymapp profile image
Maksym Kulikovskiy • Edited

next build is only needed when you'll be serving your build with next start in Production environment.
On local dev environment, next dev is all you need.
In practice, what I've seen about Next.js is that running next dev after next build simply overwrites the existing build directory, so yeah next build is redundant.

The npm run dev, is optimized to run you local code with hot-reload. It is not meant for serving your dynamic site. When you use npm run build && npm run start, it creates a better-optimized output suitable for serving your site contents with code splitting and other good stuff. However, you have to understand how your data-fetching requests ( here authentication requests) work.
from github.com/vercel/next.js/discussi...