{"name":"react-helmet-async","version":"0.2.1-0","description":"Thread-safe Helmet for React 16+ and friends","main":"lib/index.js","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","typings":"index.d.ts","dependencies":{"invariant":"^2.2.4","prop-types":"^15.6.1","react-fast-compare":"^2.0.2","shallowequal":"^1.0.2"},"devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.3","babel-eslint":"^8.2.3","babel-jest":"^22.4.4","babel-plugin-transform-class-properties":"^6.24.1","babel-plugin-transform-es2015-modules-commonjs":"^6.26.2","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-preset-kyt-react":"^0.3.0","enzyme":"^3.3.0","enzyme-adapter-react-16":"^1.1.1","eslint":"^4.19.1","eslint-config-airbnb":"^16.1.0","eslint-config-kyt":"^0.5.0","eslint-config-prettier":"^2.9.0","eslint-plugin-import":"^2.12.0","eslint-plugin-jest":"^21.17.0","eslint-plugin-json":"^1.2.0","eslint-plugin-jsx-a11y":"^6.0.3","eslint-plugin-prettier":"^2.6.0","eslint-plugin-react":"^7.9.1","jest-cli":"^22.4.4","jsdom":"^11.11.0","prettier":"^1.13.5","prettier-eslint-cli":"^4.7.1","raf":"^3.4.0","react":"^16.4.1","react-dom":"^16.4.1","regenerator-runtime":"^0.11.1"},"peerDependencies":{"react":"^16.4.2","react-dom":"^16.4.2"},"scripts":{"test":"jest","compile":"npm run compile:commonjs && npm run compile:es","compile:commonjs":"babel src --out-dir lib","compile:es":"babel src --out-dir es","prepare":"npm run compile"},"jest":{"setupTestFrameworkScriptFile":"<rootDir>/jest.setup.js","testEnvironment":"node","testMatch":["**/__tests__/**/*.test.js"],"testPathIgnorePatterns":["/node_modules/","/src/","/lib/"]},"readme":"# react-helmet-async\n\n[![CircleCI](https://circleci.com/gh/staylor/react-helmet-async.svg?style=svg)](https://circleci.com/gh/staylor/react-helmet-async)\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## Usage\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 ReactDOM from 'react-dom';\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\nReactDOM.hydrate(\n  app,\n  document.getElementById(‘app’)\n);\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## 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## License\n\nLicensed under the Apache 2.0 License, Copyright © 2018 Scott Taylor\n","readmeFilename":"README.md","gitHead":"bad7b0f103eec3794ba6867f21d6dfe51d805ed5","bugs":{"url":"https://github.com/NYTimes/react-helmet-async/issues"},"homepage":"https://github.com/NYTimes/react-helmet-async#readme","_id":"react-helmet-async@0.2.1-0","_npmVersion":"6.4.1","_nodeVersion":"10.10.0","_npmUser":{"name":"wonderboymusic","email":"scott.c.taylor@mac.com"},"dist":{"integrity":"sha512-QS7iPMLsVR6jK7QRkB5s675XzrgG1ZrB6Cz/N0FoX2sConG0QeVvo9JmZKYTYr7VBx2474Lh1Pi29dcTKKpsoA==","shasum":"746c7e040b7fbbc34146c7edb98462a40e196b1e","tarball":"http://registry-npm.ywwl.com/react-helmet-async/download/react-helmet-async-0.2.1-0.tgz","fileCount":21,"unpackedSize":104218,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbx7doCRA9TVsSAnZWagAAEsAP+wQWQP1EYK9XKPZYuzj/\nqn4MJhpNOW6qvZMTU6m8YfSB1PJudprblH4AqyyFCERQVca1s+7sYEjCna9n\nhidPTTgjcp88ocJMLCSYommmZKZdGRWQcnE3We0uqA7LReInpVwTct9yMR3F\nBjaOWI5deT8mAFm4E2VwZEmQaoHoF8WYgHIg/WE87kJKxEZky5KSiM5lQllI\n4y3AatFwb9Q2Hc2P2D4l/GcF+FH7S4o8qG7ABGcf9Eodd82H3HCtc5R2B+K1\nefWsXxuHjEg01mr+fzWAobN1P7xnBKbsNC29vqtc6X9xEmnfCRH+WU9yBgDG\n/yLG8CS6vrpRV0coO+gbL0B/OSBR2kF954hndzX7AjYZHztntqT/qtEuzWHD\nLflmuwMG2FLzgIcQoV7U0ZtjQqd89RnMKQQTzyelDz9Osr4bP9k8azG5Dh2I\nbAu6JAfFTft4Tn76qx4LZLkxHaslNG7ubQuyhc9S5XbRzvwKYE9mmyHnh2B5\navwh2W56+22UDiKHQpjlgIjIWiWcFY1Xm8Iil/C5epvVszc4MtKoFLf45Xz/\ngP3nkRnZ8tOxu2u9VT58sLYJuQ4BGqXtpEpvBMZBtYEokMOtHf3YMoxyR6e7\nrKhRNtfXiUtSwVknYJu7ayvFvu9sVwyW+K2ARKEKHzYXr+uABj/cYmHbpAhC\njFom\r\n=j797\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCWw9ExiDChhMU8gHdwvtXq43X2edEmuJt8gWAcpMmEZAIgVrjm+NKcIUupCpFmLj2o2i2ax9cQhKPx+t0WBfnW2AU="}],"size":23213,"noattachment":false,"key":"/react-helmet-async/-/react-helmet-async-0.2.1-0.tgz"},"maintainers":[{"name":"wonderboymusic","email":"scott.c.taylor@mac.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-helmet-async_0.2.1-0_1539815271511_0.4442396869677665"},"_hasShrinkwrap":false,"publish_time":1539815271627,"_cnpm_publish_time":1539815271627,"dist-tags":{"alpha":"2.0.5-alpha","beta":"2.0.5-beta","latest":"3.1.0","next":"2.0.5-next"}}