{"id":20323562,"url":"https://github.com/reacttips-dev/useragent","last_synced_at":"2025-04-11T19:32:35.682Z","repository":{"id":204115105,"uuid":"412099061","full_name":"reacttips-dev/useragent","owner":"reacttips-dev","description":"User agent parser internal library used by Facebook team","archived":false,"fork":false,"pushed_at":"2021-11-22T02:29:05.000Z","size":9755,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T15:21:17.499Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/reacttips-dev.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-09-30T14:31:52.000Z","updated_at":"2025-03-03T02:17:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"19428514-b871-4e8a-8044-b96fcabe25fd","html_url":"https://github.com/reacttips-dev/useragent","commit_stats":null,"previous_names":["reacttips-dev/useragent"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reacttips-dev%2Fuseragent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reacttips-dev%2Fuseragent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reacttips-dev%2Fuseragent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reacttips-dev%2Fuseragent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reacttips-dev","download_url":"https://codeload.github.com/reacttips-dev/useragent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248466877,"owners_count":21108554,"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":[],"created_at":"2024-11-14T19:28:40.189Z","updated_at":"2025-04-11T19:32:35.674Z","avatar_url":"https://github.com/reacttips-dev.png","language":"JavaScript","readme":"# UserAgent\nThis package is same as useragent that Facebook's team uses in their products.\n\n## Install\n```bash\nyarn add @reacttips/useragent\n\nor\n\nnpm install @reacttips/useragent\n```\n## How to use\nLet's assume that we have user agent data as following:\n```javascript\nconst userAgentData = {\n    browserArchitecture: '32',\n    browserFullVersion: '7.0',\n    browserName: 'Mobile Safari',\n    deviceName: 'iPhone',\n    engineName: 'WebKit',\n    engineVersion: '537.51.2',\n    platformArchitecture: '64',\n    platformFullVersion: '7.1.2',\n    platformName: 'iOS',\n}\n```\n\nThere are some methods that you can use:\n\n### isBrowser(query: string)\n\n```javascript\n// Use to detect by browser name\nUserAgent.isBrowser('Mobile Safari') // true\nUserAgent.isBrowser('Chrome') // false\nUserAgent.isBrowser('Mobile Safari *') //true\n\n// detect scope to specific versions\nUserAgent.isBrowser('Mobile Safari *') // true\nUserAgent.isBrowser('Mobile Safari 7') // true\nUserAgent.isBrowser('Mobile Safari 7.0 - 7.1') // true\nUserAgent.isBrowser('Chrome *') // false\nUserAgent.isBrowser('Mobile Safari 6.0.1') // false\n```\n\n### isBrowserArchitecture(query: string)\n```javascript\n// Use to detect by browser architecture\nUserAgent.isBrowserArchitecture('32') // true\nUserAgent.isBrowserArchitecture('64') // false\n```\n\n### isPlatformArchitecture(query: string)\n```javascript\n// Use to detect by browser architecture\nUserAgent.isPlatformArchitecture('32') // false\nUserAgent.isPlatformArchitecture('64') // true\n```\n\n### isDevice(query: string)\n```javascript\n// Use to detect by device name\nUserAgent.isDevice('iPhone') // true\nUserAgent.isDevice('iPad') // false\n\n// User to check does not expose version information\nUserAgent.isDevice('iPhone *') // false\nUserAgent.isDevice('iPhone 5s') // false\n```\n\n### isEngine(query: string)\n\n```javascript\n// Use to detect by engine name\nUserAgent.isEngine('WebKit') // true\nUserAgent.isEngine('Gecko') // false\n\n// Use to check scope to specific versions\nUserAgent.isEngine('WebKit *') // true\nUserAgent.isEngine('WebKit 537.51.2') // true\nUserAgent.isEngine('WebKit ~\u003e 537.51.0') // true\nUserAgent.isEngine('Gecko *') // false\nUserAgent.isEngine('WebKit 536.0.0') // false\n```\n\n### isPlatform(query: string)\n\n```javascript\n// Use to detect by platform name\nUserAgent.isPlatform('iOS') // true\nUserAgent.isPlatform('Windows') // false\n\n// Use to check scope to specific versions\nUserAgent.isPlatform('iOS *') // true\nUserAgent.isPlatform('iOS 7.1.2') // true\nUserAgent.isPlatform('iOS 7.1.x || 6.1.x') // true\n\nUserAgent.isPlatform('Windows *') // false\nUserAgent.isPlatform('iOS 6') // false\n```\n### Other uses\n\nWe can also use to normalize Windows version numbers. Let's assume\nuser agent has:\n```javascript\nconst userAgent = {\n    //... other properties\n    platformName: 'Windows',\n    platformFullVersion: '4.0',\n}\n```\nThen we can use:\n```javascript\nUserAgent.isPlatform('Windows') // true\nUserAgent.isPlatform('Windows NT4.0') // true\nUserAgent.isPlatform('Windows Vista') // false\n```\n## License\nAll code of this repo has been written by Facebook. React Tips team\ndoes not keep copyright them. We only package them to the npm package\nto help people use it more easy.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freacttips-dev%2Fuseragent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freacttips-dev%2Fuseragent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freacttips-dev%2Fuseragent/lists"}