简体   繁体   中英

Does nextjs prerender only for the first page load/refresh

I'm learning nextjs and read in a few places that nextjs only prerenders for the first page( How is server-side rendering compatible with single-page applications? )

But when I use the Link tag and navigate to another page, and view page source, I see it has the html elements that are built using data from getServerSideProps , but in.network tab there's no request for html file, only a get request that receives json data for the page. So if it prerenders only for the first page / on refresh, how does the view page source have the html elements created using react?

NextJS does pre-render to accelerate loading HTML from the server and so the SEO score, but when you are already on the website you do not need to load the whole new page HTML again, it will only un React to change components displayed.

You can see in the.network tab on your browser this happening, the first page is fully loaded while the others load a.json file containing informations on ho to change the current page.

Also when you get to see the page source code you make a new request so you get the HTML for the new URL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM