I was working on a single page application in react.js, so what is the best way to update meta tags on page transitions or browser back/forward?
You almost definitely want to use:
In contrast to react-meta-tags
it can nest
s and so you can define your meta tags deep within your app - like
s that should override each other. And in contrast to react-document-meta
you can define things using jsx (and nest things).
This seems to be the solution that the community almost exclusively uses - 600,000 weekly downloads vs the 6,000 given in other solutions. "Helmet takes plain HTML tags and outputs plain HTML tags. It's dead simple, and React beginner friendly." - and has support for server-side rendering.
Here's an example, adapted from the front page:
I'm a parent
My Title
I'm a child
Nested Title
outputs:
Nested Title
I'm a parent
I'm a child