Document Metadata Components: <title>, <meta>
You'll learn how React 19 automatically hoists metadata tags to the document <head>, letting you declare them anywhere in your component tree.
The Old Way vs The New Way
Traditionally, managing document metadata in React required third-party libraries like react-helmet or manually manipulating the DOM. You had to ensure these tags ended up in the <head> element, which meant special rendering logic or separate metadata components.
React 19 changes this: you can now render <title> and <meta> tags directly in your components, and React automatically moves them to the <head> where browsers expect them.
How It Works
Think of metadata tags like mail with a special delivery address. No matter where you drop them in your component tree, React acts as a postal service that ensures they arrive at the correct destination—the document <head>.
function ProductPage({ product }) {
return (
<div>
<title>{product.name} - My Store</title>
<meta name="description" content={product.description} />
<h1>{product.name}</h1>
<p>{product.description}</p>
</div>
);
}
Even though these tags appear inside a <div>, React hoists them to <head> automatically. This means metadata lives with the component that needs it—no more centralized metadata management or prop drilling.
Why This Matters
This feature makes metadata local to your components. Each route or feature can declare its own <title> without worrying about where it renders in the tree. It's especially powerful for SEO and social sharing, where different pages need different metadata.
Key Takeaway: In React 19, you can render <title>, <meta>, and other metadata tags anywhere in your components—React automatically hoists them to <head>, making metadata management simpler and more component-local.