{"name":"react-device-detect","version":"1.7.5","description":"Detect device type and render your component according to it","main":"dist/index.js","typings":"./index.d.ts","license":"MIT","repository":{"type":"git","url":"git+https://github.com/duskload/react-device-detect.git"},"keywords":["useragent","mobile","phone","tablet","detect","device","browser","smart-tv","smarttv","version","model","console"],"peerDependencies":{"react":"^0.14.0 || ^15.0.0 || ^16","react-dom":"^0.14.0 || ^15.0.0 || ^16"},"scripts":{"test":"jest","test:watch":"jest --watch","cover":"jest --coverage","start":"webpack --watch","build":"webpack"},"jest":{"setupFiles":["./.jestSetup.js"],"coveragePathIgnorePatterns":["/node_modules/","./.jestSetup.js"]},"author":{"name":"Michael Laktionov","email":"duskload@gmail.com"},"devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-jest":"^21.2.0","babel-loader":"^7.1.2","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-plugin-transform-react-jsx":"^6.24.1","babel-preset-env":"^1.6.0","enzyme":"^3.1.0","enzyme-adapter-react-16":"^1.0.1","jest":"^24.8.0","raf":"^3.4.0","react-test-renderer":"^16.0.0","ua-parser-js":"^0.7.18","webpack":"^3.7.1"},"gitHead":"15828e67f3e9e63c29546a12326b3a841e02b8cd","bugs":{"url":"https://github.com/duskload/react-device-detect/issues"},"homepage":"https://github.com/duskload/react-device-detect#readme","_id":"react-device-detect@1.7.5","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"duskload","email":"duskload@gmail.com"},"dist":{"integrity":"sha512-ccgJuTHVCI3yfqvgU56gQDvjueFyaHVAXsa5rJuzWRasvsd0IalzfyccSECIlygjv3E+DmAGcwNYWUarUA82Fw==","shasum":"04c8a6475d67b5ac4f984c8d912ec11134f5b893","tarball":"http://registry-npm.ywwl.com/react-device-detect/download/react-device-detect-1.7.5.tgz","fileCount":7,"unpackedSize":55840,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdOGnxCRA9TVsSAnZWagAARZ8P/2AUurJQHORicxIC0W7p\n+nebVrnLGVXfB3FD66ja4fRV/ynmazQP9IsqXG7j1bbQRcGglwxteuAP/0Xr\nKWB0qX37Owm3Yrl+SReFgDHzaSprq3FVdTqzI859eyv7FEVPNx+6v4Kr7IzX\ntyunvQ7S7bT77WAci9flbgtD3JHb8IIM8SkFVaDfozbUVmfuXsYxrXBzJay7\nhhIms6a6boWmpl/Apal42AFX8hXhpuHoPPQSsOA85DIlE0eTXA8gsWGBeFJu\n/LSs5bBairTlimb1bT8wqJwzW8R/ln4bGAykdPDDH1OzSHmRugsVGH6pCjg2\niaaqljFTxx2kMhB4e6vWmaBVB3xo9I01cMHe1nbpasJjj65YcWsbuT8yLyGe\nyiPsmG3S8EODbtF+Vax7i5uI15KFwhB9RuZyQJF6Aj7H6hXEjUUZt2VEogpJ\nsOppJnd34Te/57Pa/z4cDl9nN76DOpuNa6SDiDfHTf3vAs/lfmkoYffSBhtr\nIBgHcJum131plnYzoNns2wPg2PDASqNPN+myiX3sWGKK3lD5VnM81nXp/U+6\nXwTKx9nfBhCmgGuGPFyS3iw8laIA7MwcTenLzdIjssyiMKnyY2jKV97+X8MM\n0W6K8UgE/yituUs0lSWHpBDLHOa0TMJELN5og1JGvE3ewPU/i9IQnE0hXA0S\nXXfs\r\n=ZVVJ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFu2+neh1vWIXJ6B6HXYzbsd2iEQCpPoPPwjZkQ36pFTAiBMzESSc4gfuCLUJz8t1XpZf5y7wTNc46fR/W3pX9rgwg=="}],"size":14564,"noattachment":false,"key":"/react-device-detect/-/react-device-detect-1.7.5.tgz"},"maintainers":[{"name":"duskload","email":"duskload@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-device-detect_1.7.5_1563978224312_0.8015448501889557"},"_hasShrinkwrap":false,"readme":"## react-device-detect\n\n![npm](https://img.shields.io/npm/dm/react-device-detect?label=npm%20downloads)\n\nDetect device, and render view according to the detected device type.\n\n## Installation\n\nTo install, you can use npm or yarn:\n\n```\nnpm install react-device-detect --save\n\nor\n\nyarn add react-device-detect\n```\n\n## When to use this library\n\nThis library uses a technique called [user agent sniffing](https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent) to detect device information. That means it works by examining the [User Agent string](https://en.wikipedia.org/wiki/User_agent) given by a browser and comparing it to a list of browser and device names it knows about. This technique works, but [has drawbacks](https://css-tricks.com/browser-detection-is-bad/) and may or may not be the right approach, depending on what you're trying to achieve. If you need to detect a specific browser type (e.g. Chrome, Safari, Internet Explorer) or specific category of device (e.g. all iPods), this library can do that. If you just want your React app to behave differently or look different on mobiles in general, [CSS `@media` queries](https://developer.mozilla.org/en-US/docs/Web/CSS/@media) and [`matchMedia`](https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia) are probably what you want. There are many libraries that can help with using `@media` queries and `matchMedia` in React projects, such as [react-responsive](https://www.npmjs.com/package/react-responsive) and [@react-hook/media-query](https://www.npmjs.com/package/@react-hook/media-query).\n\n## API\n\n- [Hooks, SSR and utilities](docs/api.md)\n- [Selectors](docs/selectors.md)\n- [Views](docs/views.md)\n\n## Usage\n\nExample:\n\n```javascript\nimport { BrowserView, MobileView, isBrowser, isMobile } from 'react-device-detect';\n```\n\n```html\n<BrowserView>\n  <h1>This is rendered only in browser</h1>\n</BrowserView>\n<MobileView>\n  <h1>This is rendered only on mobile</h1>\n</MobileView>\n```\n\nif you don't need a view, you can use `isMobile` for conditional rendering\n\n```javascript\nimport {isMobile} from 'react-device-detect';\n\nfunction App() {\n  renderContent = () => {\n    if (isMobile) {\n      return <div> This content is available only on mobile</div>\n    }\n    return <div> ...content </div>\n  }\n\n  render() {\n    return this.renderContent();\n  }\n}\n```\n\nIf you want to leave a message to a specific browser (e.g IE), you can use `isIE` selector\n\n```javascript\nimport { isIE } from 'react-device-detect';\n\nfunction App() {\n  render() {\n    if (isIE) return <div> IE is not supported. Download Chrome/Opera/Firefox </div>\n    return (\n      <div>...content</div>\n    )\n  }\n}\n```\n\nIf you want to render a view on a specific device and with a specific condition:\n\n```javascript\nimport { browserName, CustomView } from 'react-device-detect';\n\nfunction App() {\n  render() {\n    return (\n      <CustomView condition={browserName === \"Chrome\"}>\n        <div>...content</div>\n      </CustomView>\n    )\n  }\n}\n```\n\n## Style the view\n\nYou can style a view component by passing class to the `className` prop\n\n```html\n<BrowserView className=\"custom-class\">\n  <p>View content</p>\n</BrowserView>\n```\n\nor you can pass inline styles to `style` prop\n\n```javascript\nconst styles = {\n  background: 'red',\n  fontSize: '24px',\n  lineHeight: '2',\n};\n```\n\n```html\n<BrowserView style={styles}>\n  <p>View content</p>\n</BrowserView>\n```\n\n### Testing\n\n```js\nimport * as rdd from 'react-device-detect';\n\nrdd.isMobile = true;\n\n// use in tests\n```\n\n## License\n\nMIT\n","publish_time":1563978224665,"_cnpm_publish_time":1563978224665,"dist-tags":{"latest":"2.2.3"}}