I've a question, I need to inject into the HEAD tag a javascript object, for tag management purposes. This is my Helmet component, but it accepts only specific parameters to set to metadata serverside through rewind() function.
Is there a way still to use React Helmet to do what I need, so, create javascritpt objects into a SCRIPT tag or should I follow a different approach?
MyComponent.js
<Helmet
title={article.get('title')}
meta={[
{"property": "og:title", "content": article.get('title')},
{"property": "og:url", "content": article.get('url')},
{"property": "twitter:title", "content": article.get('title')}
]}
/>
server.js
let htmlHead = `
${head.title}
${head.meta.toString()}
`;
Thank you for the support
React Helmet is a library that helps you deal with search engines and social media crawlers by adding meta tags to your pages/components on React so your site gives more valuable information to the crawlers. “This reusable React component will manage all of your changes to the document head.
The react-helmet is also a well-known npm package mostly used for adding an element at the head of a react document. We can add a script tag inside the head of the document using this package.
React Helmet can be termed as the document head manager for React-based applications. Using it, it becomes very easy for developers to update meta tags present on the server-side and the client-side. This library can be termed perfect for applications where SEO plays a crucial role.
Th existing answers are outdated. You don't need to contort the code with script
attributes or innerHTML
. You can use the <script>
tag as usual in HTML:
<Helmet>
<script src="https://some.host/api.js" type="text/javascript" />
</Helmet>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With