{"name":"react-helmet-async","version":"1.0.0","description":"Thread-safe Helmet for React 16+ and friends","main":"lib/index.js","umd:main":"lib/index.umd.js","module":"lib/index.mjs","source":"src/index.js","types":"index.d.ts","repository":{"type":"git","url":"git+ssh://git@github.com/NYTimes/react-helmet-async.git"},"author":{"name":"Scott Taylor","email":"scott.c.taylor@mac.com"},"license":"Apache-2.0","dependencies":{"@babel/runtime":"7.3.4","invariant":"2.2.4","prop-types":"15.7.2","react-fast-compare":"2.0.4","shallowequal":"1.1.0"},"devDependencies":{"@babel/cli":"7.2.3","@babel/core":"7.3.4","@babel/plugin-proposal-class-properties":"7.3.4","babel-eslint":"10.0.1","babel-preset-kyt-react":"1.0.0-alpha.365f23ad","enzyme":"3.9.0","enzyme-adapter-react-16":"1.10.0","enzyme-to-json":"3.3.5","eslint":"5.15.1","eslint-config-airbnb":"17.1.0","eslint-config-kyt":"1.0.0-alpha.365f23ad","eslint-config-prettier":"4.1.0","eslint-plugin-import":"2.16.0","eslint-plugin-jest":"22.3.0","eslint-plugin-json":"1.4.0","eslint-plugin-jsx-a11y":"6.2.1","eslint-plugin-kyt":"1.0.0-alpha.365f23ad","eslint-plugin-prettier":"3.0.1","eslint-plugin-react":"7.12.4","jest":"24.3.1","jsdom":"11.12.0","microbundle":"0.11.0","prettier":"1.16.4","raf":"3.4.1","react":"16.8.4","react-dom":"16.8.4","rimraf":"2.6.3"},"peerDependencies":{"react":"^16.6.0","react-dom":"^16.6.0"},"scripts":{"clean":"rimraf lib","lint":"eslint .","lint-fix":"eslint . --fix","test":"KYT_ENV_TYPE=test jest --no-cache","test-watch":"npm run test -- --watch","test-update":"npm run test -- -u","compile":"npm run clean && KYT_ENV_TYPE=client NODE_ENV=production microbundle --jsx React.createElement","prepare":"npm run compile"},"jest":{"setupFilesAfterEnv":["<rootDir>/jest.setup.js"],"testEnvironment":"node","testMatch":["**/__tests__/**/*.test.js"],"testPathIgnorePatterns":["/node_modules/","/src/","/lib/","/es/"]},"gitHead":"9a43be9a8e8d4037fba8b8806eb836cc6d745426","bugs":{"url":"https://github.com/NYTimes/react-helmet-async/issues"},"homepage":"https://github.com/NYTimes/react-helmet-async#readme","_id":"react-helmet-async@1.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.10.0","_npmUser":{"name":"wonderboymusic","email":"scott.c.taylor@mac.com"},"dist":{"integrity":"sha512-+6hVTkPlYdUGDSuJ6eBwsM4BAUEN+J49RbUnehcYeQ80MrOdrnGjvTumJXSNxL3R9709e85sNlpKauOhc3LmuA==","shasum":"6cb00424374e49de7d29f69c71b04a9f7d44e374","tarball":"http://registry-npm.ywwl.com/react-helmet-async/download/react-helmet-async-1.0.0.tgz","fileCount":17,"unpackedSize":216344,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJckl2/CRA9TVsSAnZWagAAkiIP/2oMh8fioR0PRvIpR4sr\ncCy6L91uSyt2oGFtM7xOHUZwz3Ns8wBAc/pRtCj0/SU0ed1ysrs6uNYtCui1\n5sON8JI4sz6Gmz636Stjlxo8deLaohk14qZF4jEquo5IbtGlXyW+LttXK1b9\nmFuOdQqoNR94vsZqAEz+/Mvt2cCW207fT7wRL2edINeQOw9pvUYOB+1wg0Dv\n97AetHeDvG4jCWjAZmY6Hi6L1S4HzL/v20L2r8A89eAeXL45nH8rggvwW3Ez\nFxPUthJZHDeCD7BYr455/5lIBqOqznCJmh2qE+RofxO92tM8+G4oAVKVL+hz\nil3peicVRpvB+lbuBwSX7DlZKphD94Z8A9RHnf37180eJ0Q+X1bZfDSs9uaK\nKhRcMLRadi8vAxOvWE15MVFl0TplZZlF3awtx0TqAAiUEs306F3Nt61VsOii\n86gxkTXNVFPIUUiiPmeYDrmhB5dt9CAEBxmmgTaeC5UOKpZD63GlrVgejvpg\nxszqUkE+neo7+N0bb7P6187tDoBd8fVWavXcquyHokjJWnUh1jPHOPPacxiB\nT3uH/fo2DAT+NGy20wXfzpqCjrVQxMsPUek13gbQwiDJBIf7xYeQtSaZ6ps9\nZ3dMEbN7cV8yl+MELkURFtFLSjOh+r1o/1lQReM/Sk4lrCLV+E7r2grDMWC0\nlwJx\r\n=D/xp\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCqniD4HDFpfR6jPf0yWV6rRJj/ZbFN+IaxZ3WjL+zqGwIhAJaasm18m3xLYw2WgcrbDsC2+bnutGBBvkuXAK8+2gDE"}],"size":60962,"noattachment":false,"key":"/react-helmet-async/-/react-helmet-async-1.0.0.tgz"},"maintainers":[{"name":"wonderboymusic","email":"scott.c.taylor@mac.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-helmet-async_1.0.0_1553096126763_0.10839564534919499"},"_hasShrinkwrap":false,"readme":"# react-helmet-async\n\n[![CI](https://github.com/staylor/react-helmet-async/actions/workflows/ci.yml/badge.svg)](https://github.com/staylor/react-helmet-async/actions/workflows/ci.yml)\n\n[Announcement post on Times Open blog](https://open.nytimes.com/the-future-of-meta-tag-management-for-modern-react-development-ec26a7dc9183)\n\nThis package is a fork of [React Helmet](https://github.com/nfl/react-helmet).\n`<Helmet>` usage is synonymous, but server and client now requires `<HelmetProvider>` to encapsulate state per request.\n\n`react-helmet` relies on `react-side-effect`, which is not thread-safe. If you are doing anything asynchronous on the server, you need Helmet to encapsulate data on a per-request basis, this package does just that.\n\n## React 19\n\nReact 19 has built-in support for hoisting `<title>`, `<meta>`, `<link>`, `<style>`, and `<script>` elements to `<head>`. Starting with version 3.0.0, this package detects the React version at runtime:\n\n- **React 19+**: `<Helmet>` renders actual DOM elements and lets React handle hoisting them to `<head>`. `<HelmetProvider>` becomes a transparent passthrough. The existing API is fully compatible — you do not need to change any code.\n- **React 16–18**: The existing behavior is preserved. `<Helmet>` collects all instances, deduplicates tags, and applies changes to the DOM via manual manipulation (client) or serializes them for the response (server).\n\n> **Note:** `htmlAttributes` and `bodyAttributes` do not have a React 19 equivalent, so they are still applied via direct DOM manipulation on both code paths.\n\nIf you are starting a new React 19 project and do not need `htmlAttributes`/`bodyAttributes`, SSR `context` serialization, `onChangeClientState`, `prioritizeSeoTags`, or `titleTemplate` support, you may not need this package at all — React 19's built-in metadata handling may be sufficient.\n\n## Usage\n\n**New in 1.0.0:** No more default export! `import { Helmet } from 'react-helmet-async'`\n\nThe main way that this package differs from `react-helmet` is that it requires using a Provider to encapsulate Helmet state for your React tree. If you use libraries like Redux or Apollo, you are already familiar with this paradigm:\n\n```javascript\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { Helmet, HelmetProvider } from 'react-helmet-async';\n\nconst app = (\n  <HelmetProvider>\n    <App>\n      <Helmet>\n        <title>Hello World</title>\n        <link rel=\"canonical\" href=\"https://www.tacobell.com/\" />\n      </Helmet>\n      <h1>Hello World</h1>\n    </App>\n  </HelmetProvider>\n);\n\ncreateRoot(document.getElementById('app')).render(app);\n```\n\nOn the server, we will no longer use static methods to extract state. `react-side-effect`\nexposed a `.rewind()` method, which Helmet used when calling `Helmet.renderStatic()`. Instead, we are going\nto pass a `context` prop to `HelmetProvider`, which will hold our state specific to each request.\n\n```javascript\nimport React from 'react';\nimport { renderToString } from 'react-dom/server';\nimport { Helmet, HelmetProvider } from 'react-helmet-async';\n\nconst helmetContext = {};\n\nconst app = (\n  <HelmetProvider context={helmetContext}>\n    <App>\n      <Helmet>\n        <title>Hello World</title>\n        <link rel=\"canonical\" href=\"https://www.tacobell.com/\" />\n      </Helmet>\n      <h1>Hello World</h1>\n    </App>\n  </HelmetProvider>\n);\n\nconst html = renderToString(app);\n\nconst { helmet } = helmetContext;\n\n// helmet.title.toString() etc…\n```\n\n> **React 19 SSR note:** When using React 19, `<title>`, `<meta>`, and `<link>` tags rendered inside `<Helmet>` are included directly in the React render output and hoisted to `<head>` by React itself. The `context` object will not be populated with helmet state on React 19. If you rely on the `context` for server rendering, you can render these tags directly in your component tree instead and let React 19 handle them natively.\n\n## Streams\n\nThis package only works with streaming if your `<head>` data is output outside of `renderToNodeStream()`.\nThis is possible if your data hydration method already parses your React tree. Example:\n\n```javascript\nimport through from 'through';\nimport { renderToNodeStream } from 'react-dom/server';\nimport { getDataFromTree } from 'react-apollo';\nimport { Helmet, HelmetProvider } from 'react-helmet-async';\nimport template from 'server/template';\n\nconst helmetContext = {};\n\nconst app = (\n  <HelmetProvider context={helmetContext}>\n    <App>\n      <Helmet>\n        <title>Hello World</title>\n        <link rel=\"canonical\" href=\"https://www.tacobell.com/\" />\n      </Helmet>\n      <h1>Hello World</h1>\n    </App>\n  </HelmetProvider>\n);\n\nawait getDataFromTree(app);\n\nconst [header, footer] = template({\n  helmet: helmetContext.helmet,\n});\n\nres.status(200);\nres.write(header);\nrenderToNodeStream(app)\n  .pipe(\n    through(\n      function write(data) {\n        this.queue(data);\n      },\n      function end() {\n        this.queue(footer);\n        this.queue(null);\n      }\n    )\n  )\n  .pipe(res);\n```\n\n> **React 19:** React 19's `renderToReadableStream` natively handles `<title>`, `<meta>`, and `<link>` hoisting during streaming, so the manual context extraction shown above is not necessary.\n\n## Usage in Jest\nWhile testing in using jest, if there is a need to emulate SSR, the following string is required to have the test behave the way they are expected to.\n\n```javascript\nimport { HelmetProvider } from 'react-helmet-async';\n\nHelmetProvider.canUseDOM = false;\n```\n\n> This is only relevant for React 16–18. On React 19, `HelmetProvider` is a passthrough and `canUseDOM` has no effect.\n\n## Prioritizing tags for SEO\n\nIt is understood that in some cases for SEO, certain tags should appear earlier in the HEAD. Using the `prioritizeSeoTags` flag on any `<Helmet>` component allows the server render of react-helmet-async to expose a method for prioritizing relevant SEO tags.\n\nIn the component:\n```javascript\n<Helmet prioritizeSeoTags>\n  <title>A fancy webpage</title>\n  <link rel=\"notImportant\" href=\"https://www.chipotle.com\" />\n  <meta name=\"whatever\" value=\"notImportant\" />\n  <link rel=\"canonical\" href=\"https://www.tacobell.com\" />\n  <meta property=\"og:title\" content=\"A very important title\"/>\n</Helmet>\n```\n\nIn your server template:\n\n```javascript\n<html>\n  <head>\n    ${helmet.title.toString()}\n    ${helmet.priority.toString()}\n    ${helmet.meta.toString()}\n    ${helmet.link.toString()}\n    ${helmet.script.toString()}\n  </head>\n  ...\n</html>\n```\n\nWill result in:\n\n```html\n<html>\n  <head>\n    <title>A fancy webpage</title>\n    <meta property=\"og:title\" content=\"A very important title\"/>\n    <link rel=\"canonical\" href=\"https://www.tacobell.com\" />\n    <meta name=\"whatever\" value=\"notImportant\" />\n    <link rel=\"notImportant\" href=\"https://www.chipotle.com\" />\n  </head>\n  ...\n</html>\n```\n\nA list of prioritized tags and attributes can be found in [constants.ts](./src/constants.ts).\n\n> **React 19:** The `prioritizeSeoTags` flag has no effect on React 19, since tags are rendered as regular JSX elements and their order in `<head>` is determined by React's rendering order.\n\n## Usage without Context\nYou can optionally use `<Helmet>` outside a context by manually creating a stateful `HelmetData` instance, and passing that stateful object to each `<Helmet>` instance:\n\n\n```js\nimport React from 'react';\nimport { renderToString } from 'react-dom/server';\nimport { Helmet, HelmetData } from 'react-helmet-async';\n\nconst helmetData = new HelmetData({});\n\nconst app = (\n    <App>\n      <Helmet helmetData={helmetData}>\n        <title>Hello World</title>\n        <link rel=\"canonical\" href=\"https://www.tacobell.com/\" />\n      </Helmet>\n      <h1>Hello World</h1>\n    </App>\n);\n\nconst html = renderToString(app);\n\nconst { helmet } = helmetData.context;\n```\n\n> **React 19:** The `helmetData` prop is ignored on React 19, since `<Helmet>` renders elements directly without the need for external state management.\n\n## Compatibility\n\n| React Version | Behavior |\n|---|---|\n| 16.6+ | Full support via `HelmetProvider` context and manual DOM updates |\n| 17.x | Full support via `HelmetProvider` context and manual DOM updates |\n| 18.x | Full support via `HelmetProvider` context and manual DOM updates |\n| 19.x+ | Renders native JSX elements; React handles `<head>` hoisting |\n\n## Development\n\n```bash\npnpm install\npnpm test            # unit tests\npnpm run test:e2e    # server + browser e2e tests\npnpm run test:all    # everything\n```\n\n## License\n\nLicensed under the Apache 2.0 License, Copyright © 2018 Scott Taylor\n","publish_time":1553096126909,"_cnpm_publish_time":1553096126909,"dist-tags":{"alpha":"2.0.5-alpha","beta":"2.0.5-beta","latest":"3.1.0","next":"2.0.5-next"}}