Next.js Discord

Discord Forum

NextJS doesn't compile until request is made. Why?

Answered
Argentine hake posted this in #help-forum
Open in Discord
Argentine hakeOP
As I enter 'npm run dev' , code doesn't get compiled but instead it only happens when I go to localhost:3000 on my browser. I dont understand whats going on
Answered by joulev
it is because in dev mode nextjs only compiles the page on-demand. building the entire project takes a lot of time, you don't want to waste time building /about when all you need is /
View full answer

4 Replies

@Argentine hake As I enter 'npm run dev' , code doesn't get compiled but instead it only happens when I go to localhost:3000 on my browser. I dont understand whats going on
it is because in dev mode nextjs only compiles the page on-demand. building the entire project takes a lot of time, you don't want to waste time building /about when all you need is /
Answer
@Argentine hake is it possible if you could link me to the docs page explaining this?
no i dont think they explain this in the documentation. on-demand compilation is the default for basically all web frameworks, so they don't see the need to document this