Answer the question
In order to leave comments, you need to log in
What exactly does Next.js render on the server?
Good afternoon! I don't have a clear understanding of what's going on in Next.js and why it's called server-side. The site of the zeit company, the developers of Next.js, looks like a regular SPA, if you look in the Network tab, then it sends a piece of JavaScript code along certain paths, the difference between the usual SPA is only that the SPA loads everything at once, and this one on demand. But I understood the server-side a little differently - the server renders the HTML and sends it to the client along with React, and the client no longer performs the initial render, but simply manages further actions. Tell me, did I understand the work of Next.js and its server rendering correctly? Thanks for the answer :)
Answer the question
In order to leave comments, you need to log in
What you see in the Network tab is not a server-rendered one, this is a SPA. SSR is what allows you to use any url from this site and the server will give you the rendered static. And then the transitions will be like a SPA.
And you misunderstood the difference. A normal SPA does not load everything at once, and also loads by routes. BUT HE DOES NOT GIVE STATICS FOR EVERY REQUEST URL.
they seem to have code-splitting "out of the box", but you can configure it yourself if
you're fine with webpack filled in the components (like water filling a dry riverbed), then all this "good" is rendered into good old html and returned to the client.
Then, on the client, react checks whether the values of the attributes data-react-checksum
of the client application and the server application match. If they match, it means that if we "lift" the client application (an expensive operation), then what we get will be the same as what the server sent. It turns out that this can be avoided. This is what react does.
Next.js does all this for you. On the one hand, this is good, you don’t have to mess with setting up server rendering, on the other hand, it’s bad, because it’s still worth knowing how everything happens in detail on the server.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question