Home > Enterprise >  My nextJs app is loading each page while navigating
My nextJs app is loading each page while navigating

Time:11-24

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

CodePudding user response:

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?

  • Have an error in one page & a page is completely fine with no errors.
  • Go on the first page which is fine and has no error, that page is loaded perfectly, but when you go on the second page's URL you will see the error.

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 the build 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

  • Related