hardFrontend

How does React 19 handle document metadata like `<title>` and `<meta>`?

311 views
01

Understand the problem

Native hoisting of title/meta/link tags into the document head.

reactreact-19metadataseo
02

Attempt it yourself

Sketch your approach before reading the solution — that's what interviews test.

Stuck? AI Nudge Available

Get a conceptual hint to guide your logic without spoiling the final implementation.

03

Study the solution

The solution is waiting

Give it an honest attempt first — then compare your thinking with the full walkthrough.

04

Explore the playground snippets

Per-page <title> hoisted to <head>
Run Playground
import { useState } from 'react';

export default function App() {
  const [page, setPage] = useState('Home');
  return (
    <div style={{ fontFamily: 'sans-serif', padding: 24 }}>
      {/* React 19 hoists these into <head> — watch the browser tab title change */}
      <title>{page + ' — My App'}</title>
      <meta name="description" content={'You are on the ' + page + ' page'} />
      <h1>{page}</h1>
      {['Home', 'About', 'Contact'].map((p) => (
        <button key={p} onClick={() => setPage(p)} style={{ marginRight: 8 }}>{p}</button>
      ))}
      <p style={{ color: '#666' }}>The document title updates as you switch pages.</p>
    </div>
  );
}
05

Join the discussion

Discussion (0)

Sign in to join the discussion.

No responses yet. Be the first to share what you think.