React Native Helmet Async

2.0.4 · active · verified Sun Apr 19

react-native-helmet-async is a specialized fork of `react-helmet-async`, which itself is a modern, thread-safe solution for managing meta tags in React applications. This particular package addresses the specific needs of React Native by removing the `react-dom` peer dependency, making it suitable for environments where DOM rendering is not present. Its core differentiator is the use of a `<HelmetProvider>` component to encapsulate Helmet state on a per-request or per-tree basis, crucial for asynchronous server-side rendering (SSR) to prevent state pollution across requests. It is currently at version 2.0.4 and appears to be actively maintained, providing an essential tool for SEO and head management in React Native web applications (when used with a web renderer) and isomorphic React projects where `react-dom` is not desired. It solves the thread-safety issues inherent in the original `react-helmet`'s `react-side-effect` dependency.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates basic client-side usage of Helmet and HelmetProvider to manage document head tags.

import React from 'react';
import { createRoot } from 'react-dom/client';
import { Helmet, HelmetProvider } from 'react-native-helmet-async';

const App = () => (
  <div>
    <Helmet>
      <title>My Awesome React Native Web App</title>
      <link rel="canonical" href="https://www.example.com/" />
      <meta name="description" content="A test application for react-native-helmet-async" />
    </Helmet>
    <h1>Welcome to the App!</h1>
    <p>Check the document head for the meta tags.</p>
  </div>
);

const container = document.getElementById('root');
if (container) {
  const root = createRoot(container);
  root.render(
    <HelmetProvider>
      <App />
    </HelmetProvider>
  );
} else {
  console.error('Root element not found. Please ensure an element with id "root" exists.');
}

view raw JSON →