- SEO
- Performance
- Javascript and Accesibility
-
Not every search engine crawler execute JS only Google and with Google must not be blocking calls.
-
You need it if you want a good SEO in Bing, Yahoo, Baidu, Yandex, AOL, etc...
-
Maybe your app doesn't need more than metatags
=> In my opinion this will be good for:
- Webs like e-commerce, online sellers, real states, etc
- Webs with more visits from search engines that are not Google
- Indeed if SSR is WELL implemented the loading will be improved
- Server Data also will come faster if we included in the HTML but this could slow down the markup download
- Disabled Javascript it is doesn't related with Accesibility, most Screen Reader runs JS
- Less than 2.4% of your visits will have disabled Javascript
- A big part is because performance issues, so you can improve it without add SSR
React, Angular, Ember and other Client framework/libraries let you render in the server side.
Prepare your app for SSR means:
- A complexity layer
- A new architecture
- New challenges
Now your app should be shared between the server and client. And handle all kind of abstraction and edge cases. Also in the goal of increase the performance you will find many blocks.
Note: Create simple apps is really easy at least with React
- Because you need client code in the server side then you will need a good wrapper for your server language at least you use NodeJS
- Also you need to create a kind of architecture to share the code between client and server and don't repeat it.
- Routes
- Components
- Data
- Server calls
We can do it after JS is downloaded and the framework is running We can do it synchronously in the first request(this it is better depending of the amount of data) => The better is a mix of both solutions
- Gap of Interaction
When the server send te first response the client can start interacting but there is a time window where the framework/lib didn't run yet so won't be any interaction => There are solutions for this issue but depends of your app and needs more code to handle the different contexts.
- Dependencies
If you work with dependencies like window, localStorage, SessionStorage, Geolocalization and other Browser API you will need a kind of wrapper
- Routes
All the client routes needs to be also in the server side
- Cache (Scalability)
- Data should be cached using Redis, memcached, etc.
- The HTML needs to be cached also and now it is not so straightfoward because you are rendering the client app in every request
- Client Libraries
You should ensure that all your libraries runs fine in the server side and doesn't have strong dependencies(mock all)
- Session State
You will need another security layer that check and return the HTML depending of the session the user is - like the common web server approach -.
- Grown
Every feature should be checked twice, and the abstraction should be clear in order to grow your application.
- Server - Client Tight coupling
The updates in the client or server will affect both places, so the risk is higher than a common application. You need to take care of this problem when the architecture is being defined
Web: https://universal.angular.io/
This is a project in progress, seems cool but is not finished yet. The documentation example is not right and is dificult to find updated and working examples. I got a running example where you can see how its working and how the implementation it is going so far.
- Build simple apps is very straightfoward. You need to work with React and ReactDOM in the server and
renderToString
does the things really easy. - React-Router also work in the server side.
- Redux can be applied too.
Note: While your app grown in complexity start becoming difficult to acchieve with server rendering, without including the new challenges.
Beginner tutorial: https://www.terlici.com/2015/03/18/fast-react-loading-server-rendering.html
Middle tutorial: https://www.smashingmagazine.com/2016/03/server-side-rendering-react-node-express/
React Router + Redux: https://www.codementor.io/reactjs/tutorial/redux-server-rendering-react-router-universal-web-app