Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which method is faster, express : Server-side rendering vs client-side rendering

What I would like to know is, how do you built your web application? I'm really confuse as which method should I use for my project.

Already decided which technologies to choose.

1) Node.js and express as its Framework

2) MongoDB

3) React + Flux

But the problem right now, should I use method (A) or method (B)

Method (A) - Serverside rendering for HTML

app.get('/users/', function(request, respond) {
     var user = "Jack";
     respond.render("user", { user: user });
});

Method (B) - Clientside rendering for HTML

 app.get('/users/', function(request, respond){ 
       var user = "Jack";
       respond.json({ user: user });
    });

Method A will render the HTML from the server and as well as the data.

Method B will just respond the data that is needed for the client which is React.js, so that it could manipulate the data.

My concern, is which method should I use? most startups use which method?

Thank you.

like image 650
Jack Moscovi Avatar asked Oct 27 '15 03:10

Jack Moscovi


1 Answers

It's not an either/or proposition.

React is a client side framework. You have to render on the client side. The question is whether to render on the server side in addition to rendering on the client side.

The answer? If you can, YES!

You will get SEO benefits and an initial performance boost by rendering on the server side. But you will still have to do the same client side rendering.

I suggestion googling "isomorphic react" and doing some reading. Here is one article on the subject. http://www.smashingmagazine.com/2015/04/react-to-the-future-with-isomorphic-apps/

like image 181
David L. Walsh Avatar answered Oct 05 '22 03:10

David L. Walsh