React 19 allows adding <title>, <meta>, and <link> directly in components.
Code:
1function BlogPost({ post }) {2 return (3 <article>4 <title>{post.title} | My Blog</title>5 <meta name="description" content={post.summary} />6 <meta property="og:title" content={post.title} />7 <meta property="og:image" content={post.image} />8 <link rel="canonical" href={`https://myblog.com/posts/${post.id}`} />910 <h1>{post.title}</h1>11 <p>{post.content}</p>12 </article>13 );14}1516// Dynamic metadata based on props17function ProductPage({ product }) {18 return (19 <div>20 <title>{product.name} | Shop</title>21 <meta name="description" content={product.description} />22 <meta name="keywords" content={product.tags.join(", ")} />23 {/* Product content */}24 </div>25 );26}
Benefits:
Stylesheets:
1function App() {2 return (3 <>4 <link rel="stylesheet" href="styles.css" precedence="default" />5 <div className="app">...</div>6 </>7 );8}
Key points:
<head> automaticallyname, property, rel attributes