Harkirat Saluja Harkirat Saluja - 1 year ago 203
React JSX Question

How to update meta tags in React.js?

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?

Answer Source

I've used react-document-meta in an older project.

Just define your meta values

const meta = {
    title: 'Some Meta Title',
    description: 'I am a description, and I can create multiple tags',
    canonical: 'http://example.com/path/to/page',
    meta: {
        charset: 'utf-8',
        name: {
            keywords: 'react,meta,document,html,tags'

and place a

<DocumentMeta {...meta} />

in the return

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download