Using prerender.io with ReactJS for SEO

I realized that my ReactJS application using a react router does not have external links. Search engines do not recognize that the site has a lot of related content. Prerender.io seems like a good solution for this, but I can't get it to work for my ReactJS application.

Can I use prerender.io with ReactJS? If not, is there another good way to improve SEO for my site without doing all the server side rendering?

EDIT: after further digging, I realized that the problem is that by default the router uses "#" and not "#!". Is it possible to work with a reactive router using "#!"

+6
source share
1 answer

Prerender seems to expect real URLs because otherwise you won’t be able to serve cached html for ordinary people (the hash is not sent to the server).

When configuring a repeater, the router provides its use in history mode:

Router.run(routes, Router.HistoryLocation, function (Handler) { 

On your server, you need to make sure that all routes that do not match the static file are served either by sending index.html or using prerender.

You can find "send all requests to index.html {insert server name here}" to find information about this.


Apparently, by default, prerender only applies in certain situations. Here is an example if you are using express.js middleware in node.js:

 require('prerender-node').shouldShowPrerenderedPage = function(){ return true } 

You should be able to find similar modifications for other middleware (it will require a plug in less flexible languages).

+2
source

Source: https://habr.com/ru/post/981637/


All Articles