cluster1
cluster1

Reputation: 5694

Server-side rendering with JavaScript frameworks: What are the benefits over established backend-technologies?

In recent times JavaScript frameworks for server-side rendering became popular. For example Next.js and Nuxt.js.

I wonder: Does those frameworks have any special benefit over established, pure backend technologies (Python Django, Ruby on Rails, PHP Laravel, ...)?

Or is it just for using the technology, you are known from the frontend, at the backend too? So that you don't have to switch between different languages.

Upvotes: 0

Views: 343

Answers (2)

Daniel
Daniel

Reputation: 15453

The purpose of server-side rendering in the world of React is to solve the problem of getting content to the user as quickly as possible, not so much because there are other backend technologies of different programming languages we don't want to bother with, after all, I have put together server-side rendering and non-server-side rendering React applications that have an Express server, so it all can be done with just JavaScript.

Now, just saying that it's to solve the problem of getting content to the user as quickly is possible may not mean anything if you don't understand that the browser requests a page...and then we wait...the browser requests a JS file...and then we wait...React app boots, it requests json from backend...and then we wait...and finally the content is visible.

Now this is not happening in hours or minutes but seconds to milliseconds, but that can make a huge difference in the success of a business. Perhaps this article from Fast Company may make the point:

https://www.fastcompany.com/1825005/how-one-second-could-cost-amazon-16-billion-sales

These big retailers have proven that loading a page as quickly as possible leads to improved conversion rates and increased user satisfaction, therefore it's in our best interest as engineers to figure out some way to condense down this loading process to be as quickly as possible and thus we have server-side rendering.

We want to get content visible to the user as quickly as possible. We want one request and...boom! the user can start enjoying the application.

Upvotes: 1

T.J. Crowder
T.J. Crowder

Reputation: 1075129

The primary advantage of frameworks like Nuxt.js is that they implement server-side rendering of client-side framework code. (In the case of Nuxt.js it's Vue.js, but there are ones for React and Angular [in fact, I think there is probably more than one for each of them].)

You write your code using the client-side framework, and you can deploy it:

  • client-side, or
  • server-side for a static site, or
  • a combination of both

...all with the same technologies (including JavaScript rather than [say] PHP, but also the same framework tech).

Server-side rendering lets you present something meaningful to bots, or pre-bake common page views rather than rendering them on the client, or load a static version quickly via edge-cached resources then "hydrate" it to make it dynamic, ...

Upvotes: 3

Related Questions