React Helmet
warning
react-helmet is no longer maintained (last release 6.1.0 in June 2020) and relies on legacy class lifecycles. Prefer react-helmet-async, or in React 19+ render <title>, <meta> and <link> directly inside components - React hoists them into the document head.
react-helmet is a reusable React component that helps manage changes to the document head, like updating the page title, adding meta tags, or linking external stylesheets.
Features
- Supports all valid head tags:
title,base,meta,link,script,noscript, andstyletags. - Supports attributes for
body,htmlandtitletags. - Supports server-side rendering.
- Nested components override duplicate head changes.
- Duplicate head changes are preserved when specified in the same component (support for tags like "apple-touch-icon").
- Callback for tracking DOM changes.
Using
import React from 'react';
import { Helmet } from 'react-helmet';
function MyComponent() {
return (
<div>
<Helmet>
<title>My Awesome App</title>
<meta name="description" content="This is my awesome application" />
<link rel="canonical" href="https://www.myawesomeapp.com" />
</Helmet>
<h1>Welcome to My Awesome App</h1>
</div>
);
}
export default MyComponent;
Related notes
- React Router
- React
- Next.js - built-in metadata handling