Why does ssr/ssg client navigation change the page source?
I can't figure out this behavior.
- I have my nuxt app rendering with ssr or ssg.
- When i land on the root route "/" it servers the index document. I right click "view source" and i can see that static markup.
- I click the nuxt-link on that page to "/test" route and i see a json payload xhr request come through: no new document in the network tab. but when i right click and view source again, i see the markup for test, not index.
I thought only the server rendered page can be seen in the rightclick -> view source?
This is a client-side navigation right? Why does it appear the original document is being altered?
3 Replies
So it seems like the document from the server only happens on the initial page request, any page routed to after that is purely client side. But I still don't understand why the page source is being modified, if it's not technically server rendered. Heres an example of the steps i posted above where the index is the originally loaded page, then i navigate via nuxt-link to /test and upon looking at the page source, the test page contents are now inside the div where the index page content was.
![No description](https://cdn.answeroverflow.com/1247568815169081434/SCR-20240604-kdes.png)
you're going to a totally different view, with SSR that's the point of the server side is to render the HTML as is... so of course index would be different than text
Isn’t only the first request rendered server side (index), then subsequent navigation in-app is rendered like a SPA? thats why i’m wondering why the page source changed for /test.
***
oh sorry, i get what is happening:
right click -> view source opens a new browser tab which becomes a server request to the page:
view-source:http://localhost:3000/test
even if the original request was client side, opening that window is a server request so the js will show there.