ShakaCode | ShakaCode Blog | Rails On Maui Blog | Rails | ReactJs | JavaScript | Webpack | Productivity |

Using react-helmet for Meta Tags when doing SSR


I’ve seen some discussions around react-helmet and why it’s needed when you can use conventional Rails techniques to put the meta tags in the page header.

The reason we need helmet is that when we’re using react-router to navigate between pages (client rendered), we want the head tags set correctly just the same way of when a direct link to a page is clicked (server rendered).

If we don’t use react-helmet, then we have to DUPLICATE the logic between the Rails code and the JS code. So, in general, we prefer SSR with react-helmet.

react-helmet usage is documented here within React on Rails.