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...
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Is
next build
necessary if you're doingnext dev
?next build
is only needed when you'll be serving your build withnext 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
afternext build
simply overwrites the existing build directory, so yeahnext build
is redundant.