Reputation: 91
I have a pretty huge NextJs app, whenever I run yarn run dev
the app is working on 3000 but whenever I click on navigate/page, each page is refreshing, like Jquery, and also my NodeJs is consuming close to 3GB of ram, so basically when I navigate my page compiling taking toooo long, I have 8GB of ram
Upvotes: 1
Views: 1663
Reputation: 1953
This is because, during development, the code is not efficiently built, and on each navigation, if the page for the URL you are visiting (if not visited earlier), Nextjs will create that page at runtime with hot-relaod
and that is why you may see that delay.
How you can test this?
This implies that on running
npm run dev
, each page is built individually and one page is only created once it is required.
On the other hand,
npm run build
creates an efficiently built bundle all the pages in thebuild
folder at once. And above example will not be built and will show some error.
You can read more about this on https://github.com/vercel/next.js/discussions/15053#discussioncomment-143243
Upvotes: 1