nfl / react-helmet

A document head manager for React
MIT License
17.34k stars 660 forks source link

Is React Helmet meant to work with CRA/SPA? #648

Open laurencefass opened 3 years ago

laurencefass commented 3 years ago

Do you want to request a feature or report a bug? dont know yet

What is the current behavior? React Helmet doesnt appear to work with a Create-React-App SPA and I can see no documented reference to use with CRA or (non-SSR) SPA's in general. If React Helmet only works with SSR it would be great to see this at the head of supporting documentation. If it is meant to work with SPA's out the box then either I am doing something wrong or something is broken but some advice on what to expect would be much appreciated.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React and react-helmet. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:

What is the expected behavior? Which versions of React and react-helmet, and which browser / OS are affected by this issue? Did this work in previous versions of React and/or react-helmet?

gabimoncha commented 2 years ago

@laurencefass you can use react-snap together with it and then it works. By nature the indexer only looks for the meta tags inside index.html file. In CRA react-helmet adds those tags during the javascript run, so the indexer won't see them. Because of this you need to have a static site.