react-helmet-async is a robust solution for managing document head tags (title, meta, link, etc.) in React applications, designed to be thread-safe for server-side rendering (SSR). It addresses the limitations of the original `react-helmet` by encapsulating state on a per-request basis through a `<HelmetProvider>`, crucial for asynchronous SSR environments. The current stable version is 3.0.0, which introduces significant adaptations for React 19+, leveraging React's native metadata hoisting capabilities while maintaining backward compatibility for React 16-18. It differentiates itself by providing a consistent API across React versions, handling `htmlAttributes` and `bodyAttributes` consistently, and offering a context for SSR data extraction, although this context behaves differently in React 19. Releases appear to follow a non-strict cadence, driven by major React version updates and feature enhancements.
npm install react-helmet-asyncVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates basic client-side usage of Helmet for managing document head attributes, title, meta, link, style, and script tags within a React application, wrapped in a HelmetProvider.
Update all imports to use named imports: `import { Helmet, HelmetProvider } from 'react-helmet-async';`If you rely on the SSR `context` object to extract `<title>`, `<meta>`, or `<link>` tags in a React 19 environment, you should instead render these tags directly in your component tree. React 19 will hoist them natively. For `htmlAttributes` and `bodyAttributes`, the context and direct DOM manipulation remain relevant.
Always wrap your React application with `<HelmetProvider>`, both on the client and server. For SSR, ensure you pass a unique `context` object to `<HelmetProvider>` for each request.
When migrating from `react-helmet`, remove `Helmet.renderStatic()` calls and instead pass a `context` object to `<HelmetProvider>` during SSR. Extract the `helmet` object from this `context` after rendering.
Change `import Helmet from 'react-helmet-async';` to `import { Helmet } from 'react-helmet-async';`Check for duplicate `react` installations using `npm ls react` or `yarn why react`. Use a tool like `resolutions` (Yarn) or `overrides` (NPM 8+) to force a single `react` version. Ensure `react` is correctly specified in `peerDependencies` and installed in your project.
For React 19+, rely on React's native head hoisting for `<title>`, `<meta>`, and `<link>`. If you need to access these tags programmatically on the server, render them directly in your component tree instead of relying solely on `Helmet` and its context extraction.