Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

getstaticprops nextjs fetch all page at first time

500 brothers. why nextjs fetch all json files at the first time I land on the page. I am used getstaticprops for those pages. I am afraid that will affect the performance.i expect that the json just should be fetched when I land on that page.
enter image description here

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Your problem is you’re using Link and by default, Link has prefetch={true} which means your page will prefetch all your data from all other pages’ links. You can check this doc.

These prefetching behaviors run in the background, so you don’t need to worry about performance.

If you are still concerned about it, you can set Link like below

<Link prefetch={false} href={...}>
   <a>...</a>
</Link>

Side note that whenever you hover on Link, it will start prefetching, although you set prefetch={false}.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading