{"id":18425262,"url":"https://github.com/burnpiro/use-ua-parser-js","last_synced_at":"2025-04-07T16:31:40.859Z","repository":{"id":46633473,"uuid":"412853439","full_name":"burnpiro/use-ua-parser-js","owner":"burnpiro","description":"React Hook built on top of UAParser.js library to detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data","archived":false,"fork":false,"pushed_at":"2024-12-21T08:30:17.000Z","size":753,"stargazers_count":5,"open_issues_count":5,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-22T21:07:45.683Z","etag":null,"topics":["browser-detector","device-detector","react-hooks","user-agent","user-agent-parser"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/burnpiro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-02T16:38:48.000Z","updated_at":"2024-12-24T17:13:11.000Z","dependencies_parsed_at":"2022-07-20T08:32:06.886Z","dependency_job_id":"e13b8344-4d50-465b-b915-2669b0d898be","html_url":"https://github.com/burnpiro/use-ua-parser-js","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/burnpiro%2Fuse-ua-parser-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/burnpiro%2Fuse-ua-parser-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/burnpiro%2Fuse-ua-parser-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/burnpiro%2Fuse-ua-parser-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/burnpiro","download_url":"https://codeload.github.com/burnpiro/use-ua-parser-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247687939,"owners_count":20979570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser-detector","device-detector","react-hooks","user-agent","user-agent-parser"],"created_at":"2024-11-06T05:03:21.101Z","updated_at":"2025-04-07T16:31:40.464Z","avatar_url":"https://github.com/burnpiro.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/burnpiro/use-ua-parser-js/master/misc/logo.png\" width=\"512\" height=\"256\"\u003e \n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://travis-ci.org/faisalman/ua-parser-js\"\u003e\u003cimg src=\"https://travis-ci.org/faisalman/ua-parser-js.svg?branch=master\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/use-ua-parser-js\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/use-ua-parser-js.svg\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# useUA React Hook\n\nReact Hook built on top of UAParser.js library to detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data\n\n- Hook author: Kemal Erdem https://erdem.pl\n- UAParse.js author : Faisal Salman \u003c\u003cf@faisalman.com\u003e\u003e\n- Demo : https://faisalman.github.io/ua-parser-js\n- Source : https://github.com/burnpiro/use-ua-parser-js\n\n# Installation\n```bash\nnpm i use-ua-parser-js\n```\n\n# Usage\n\n```javascript\nimport { useUA } from 'use-ua-parser-js';\n\nconst myComponent: FC\u003cProps\u003e = (props) =\u003e {\n  const UADetails = useUA(); //get current browser data\n  [...]\n}\n```\n\nReturn:\n```typescript\n{\n  ua: string,\n  browser: { name: string, version: string },\n  cpu: { architecture: string },\n  device: { model: string, type: string, vendor: string },\n  engine: { name: string, version: string },\n  os: { name: string, version: string }\n}\n```\n\n### Options\n\nParse custom userAgent:\n\n```javascript\n\nimport { useUA } from 'use-ua-parser-js';\n\nconst customAgent = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_1_1 like Mac OS X; en) AppleWebKit/534.46.0 (KHTML, like Gecko) CriOS/19.0.1084.60 Mobile/9B206 Safari/7534.48.3';\nconst myComponent: FC\u003cProps\u003e = (props) =\u003e {\n  const UADetails = useUA(customAgent);\n  [...]\n}\n```\n\n# Other Hooks\n\n### `useDevice(uaString?: string)`:\n\n```javascript\n\nimport { useDevice } from 'use-ua-parser-js';\n\nconst myComponent: FC\u003cProps\u003e = (props) =\u003e {\n  const device = useDevice(); //{ model: string, type: string, vendor: string }\n}\n```\n\n### `useBrowser(uaString?: string)`:\n\n```javascript\n\nimport { useBrowser } from 'use-ua-parser-js';\n\nconst myComponent: FC\u003cProps\u003e = (props) =\u003e {\n  const browser = useBrowser(); //{ name: string, version: string }\n}\n```\n\n### `useCPU(uaString?: string)`:\n\n```javascript\n\nimport { useCPU } from 'use-ua-parser-js';\n\nconst myComponent: FC\u003cProps\u003e = (props) =\u003e {\n  const cpu = useCPU(); //{ architecture: string }\n}\n```\n\n### `useEngine(uaString?: string)`:\n\n```javascript\n\nimport { useEngine } from 'use-ua-parser-js';\n\nconst myComponent: FC\u003cProps\u003e = (props) =\u003e {\n  const engine = useEngine(); //{ name: string, version: string }\n}\n```\n\n## Helpers\n\n### `isMobile(device: UAParser.IResult['device']): boolean`\n\n```javascript\nimport { useDevice, isMobile } from 'use-ua-parser-js';\n\nconst myComponent: FC\u003cProps\u003e = (props) =\u003e {\n  const device = useDevice(); //{ model: string, type: string, vendor: string }\n  const isCurrentDeviceMobile = isMobile(device);\n}\n```\n\n### `isTouchDevice(device: UAParser.IResult['device']): boolean`\nCheck if device is either a `mobile`, `tablet` or `wearable` device. Doesn't include \"2:1\" laptops.\n\n```javascript\nimport { useDevice, isTouchDevice } from 'use-ua-parser-js';\n\nconst myComponent: FC\u003cProps\u003e = (props) =\u003e {\n  const device = useDevice(); //{ model: string, type: string, vendor: string }\n  const hasTouchScreen = isTouchDevice(device);\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fburnpiro%2Fuse-ua-parser-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fburnpiro%2Fuse-ua-parser-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fburnpiro%2Fuse-ua-parser-js/lists"}