Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsMay 19, 2026·3 min de lecture

React Helmet — Document Head Manager for React

A reusable React component that manages changes to the document head, making it easy to set page titles, meta tags, and other head elements per route.

Prêt pour agents

Cet actif peut être lu et installé directement par les agents

TokRepo expose une commande CLI universelle, un contrat d'installation, le metadata JSON, un plan selon l'adaptateur et le contenu raw pour aider les agents à juger l'adaptation, le risque et les prochaines actions.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
React Helmet Overview
Commande CLI universelle
npx tokrepo install 3fa4fb4e-535c-11f1-9bc6-00163e2b0d79

Introduction

React Helmet is a component that manages the document <head> in React applications. It allows each page or component to declare its own title, meta tags, link elements, and scripts. When multiple Helmet instances are mounted, the last one wins, making it natural to set defaults at the layout level and override per page.

What React Helmet Does

  • Sets document title, meta tags, and Open Graph data per route
  • Manages link, script, style, and base elements in the head
  • Supports server-side rendering for SEO-critical head output
  • Deduplicates head elements automatically
  • Provides an async variant (react-helmet-async) for concurrent rendering

Architecture Overview

React Helmet collects head element declarations from mounted components and applies them to the real DOM head via side effects. It uses a last-wins strategy: nested or later-mounted Helmet instances override earlier ones. On the server, Helmet.renderStatic() captures the final head state as strings for SSR injection. The async fork (react-helmet-async) replaces the global side-effect model with a context-based approach for thread safety.

Self-Hosting & Configuration

  • Install react-helmet or react-helmet-async for concurrent mode
  • Place a default <Helmet> in your root layout with fallback title and meta
  • Override specific tags in child route components
  • For SSR, call Helmet.renderStatic() after renderToString() to extract head HTML
  • Use titleTemplate="%s | My App" for consistent title suffixes

Key Features

  • Declarative head management using plain JSX
  • Server-side rendering support for search engine indexing
  • Automatic deduplication of meta tags by name or property
  • Nested overrides follow component hierarchy naturally
  • Drop-in async variant for React 18 concurrent features

Comparison with Similar Tools

  • react-helmet-async — fork of Helmet with context-based API, recommended for React 18+
  • Next.js Head — built into Next.js, no extra dependency needed in Next apps
  • Remix meta — route-based meta exports, integrated with Remix loader data
  • Unhead — framework-agnostic, works with Vue, React, and Solid
  • React 19 Metadata — upcoming built-in metadata API in React itself

FAQ

Q: Should I use react-helmet or react-helmet-async? A: Use react-helmet-async for new projects. It avoids global state issues and supports concurrent rendering.

Q: Does it work with React Router? A: Yes, place Helmet in each route component to set per-page titles and meta tags.

Q: How do I set Open Graph tags for social sharing? A: Add <meta property="og:title" content="..." /> inside your Helmet component.

Q: Can I add inline scripts via Helmet? A: Yes, but be cautious with user-provided content to avoid XSS. Prefer external script sources.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires