Hi Brandon, I'm really glad the article pushed you to start working with SSR !
If I understood your first question correctly, you'd have an Express server that handles usual operations while having a client built using Next and server-rendered.
Either way, your individual pages would be queried to the server at each route. Doing REST, CRUD and authentication operations by querying your server is one thing, but getting the HTML on each route is another.
For your second question, I understand the confusion, so let me clarify:
Imagine you have an e-mail under /inbox/42 where 42 is the e-mail's ID. The index.html page related to this specific e-mail would need to be already rendered on the server in order for it to be SSR. This way, when you reach this page, the complete page (and therefore its content) would be received by the client.
In an SPA case, the data for the e-mail with an ID of 42 would be queried to the server as you'd normally do.
I really hope this helps, and thank you for your feedback !
Gotcha, definitely cleared up what I was thinking, thank you.
So I guess another question is what is technically SSR? You touch on it a bit in this post but with everything getting data from a RESTful endpoint this would typically mean even a simple blog grabbing a posts' content from a database wouldn't be considered SSR correct?
For example, if using Next and React, when requesting a blog post I would have a fetch request inside of the componentDidMount() method which is only called after the initial render() method. The way you've explained the Gmail scenario makes me think that this is no longer considered SSR even if using Next to render the page, correct? Another thought is that perhaps all of this is done on the server side, going through all of the React Component LifeCycle Methods before actually sending the HTML to the client which if that's the case then that would be considered SSR.
Is there a way to have a SSR SPA hybrid? So on the first request, it acquires a server rendered page and then all clicks after that work with a SPA which makes RESTful calls?
An experienced software developer with a strong background in developing award-winning web and mobile applications for diverse clients with 6+ years of industry experience.
If you want to go futher, checkout LiveView, it returns complete layout in html/css on the initial get request, then use websocket to push user interaction to the server.
The server maintain the virtual dom, and send the diff patch to the client for partial update.
This way the client don't need to download heavy javascript bundles. It has two implementations so far, in typescript and elixir
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi Brandon, I'm really glad the article pushed you to start working with SSR !
If I understood your first question correctly, you'd have an Express server that handles usual operations while having a client built using Next and server-rendered.
Either way, your individual pages would be queried to the server at each route. Doing REST, CRUD and authentication operations by querying your server is one thing, but getting the HTML on each route is another.
For your second question, I understand the confusion, so let me clarify:
Imagine you have an e-mail under
/inbox/42
where 42 is the e-mail's ID. Theindex.html
page related to this specific e-mail would need to be already rendered on the server in order for it to be SSR. This way, when you reach this page, the complete page (and therefore its content) would be received by the client.In an SPA case, the data for the e-mail with an ID of 42 would be queried to the server as you'd normally do.
I really hope this helps, and thank you for your feedback !
Gotcha, definitely cleared up what I was thinking, thank you.
So I guess another question is what is technically SSR? You touch on it a bit in this post but with everything getting data from a RESTful endpoint this would typically mean even a simple blog grabbing a posts' content from a database wouldn't be considered SSR correct?
For example, if using
Next
andReact
, when requesting a blog post I would have afetch
request inside of thecomponentDidMount()
method which is only called after the initialrender()
method. The way you've explained the Gmail scenario makes me think that this is no longer considered SSR even if usingNext
to render the page, correct? Another thought is that perhaps all of this is done on the server side, going through all of theReact Component LifeCycle Methods
before actually sending the HTML to the client which if that's the case then that would be considered SSR.Is there a way to have a SSR SPA hybrid? So on the first request, it acquires a server rendered page and then all clicks after that work with a SPA which makes RESTful calls?
Nuxt and Next already do this. You only reach the server on the first request and then everything else works like a spa
Same with Gatsby.
If you want to go futher, checkout LiveView, it returns complete layout in html/css on the initial get request, then use websocket to push user interaction to the server.
The server maintain the virtual dom, and send the diff patch to the client for partial update.
This way the client don't need to download heavy javascript bundles. It has two implementations so far, in typescript and elixir