{"id":28357451,"url":"https://github.com/rastislavcore/device-sherlock","last_synced_at":"2026-05-15T01:39:50.839Z","repository":{"id":237894276,"uuid":"795439640","full_name":"rastislavcore/device-sherlock","owner":"rastislavcore","description":"Device detector module for js","archived":false,"fork":false,"pushed_at":"2024-05-06T18:46:44.000Z","size":92,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-04T00:32:02.025Z","etag":null,"topics":["device","device-detection","device-detector","sherlock"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rastislavcore.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2024-05-03T09:33:20.000Z","updated_at":"2024-05-06T18:46:26.000Z","dependencies_parsed_at":"2024-05-03T14:12:48.511Z","dependency_job_id":"e16e669f-196a-47dd-9326-cef482eed574","html_url":"https://github.com/rastislavcore/device-sherlock","commit_stats":null,"previous_names":["rastislavcore/device-sherlock"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/rastislavcore/device-sherlock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rastislavcore%2Fdevice-sherlock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rastislavcore%2Fdevice-sherlock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rastislavcore%2Fdevice-sherlock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rastislavcore%2Fdevice-sherlock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rastislavcore","download_url":"https://codeload.github.com/rastislavcore/device-sherlock/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rastislavcore%2Fdevice-sherlock/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33050631,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["device","device-detection","device-detector","sherlock"],"created_at":"2025-05-28T08:05:40.326Z","updated_at":"2026-05-15T01:39:50.831Z","avatar_url":"https://github.com/rastislavcore.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Device Sherlock\n\nPowerful, lightweight device detector module.\n\n\u003e Available for Javascript, Typescript, Vue, React and Angular\n\nNote: This module is not a device detector, it's a device type detector. This module is ECMAScript modules (ESM) only.\n\n## Installation\n\nNPM:\n\n```bash\nnpm i device-sherlock\n```\n\nPNPM:\n\n```bash\npnpm add device-sherlock\n```\n\nYarn:\n\n```bash\nyarn add device-sherlock\n```\n\n## Use\n\n```ts\nimport { deviceSherlock } from 'device-sherlock';\n```\n\nor:\n\n```ts\nimport pkg from 'device-sherlock';\nconst { deviceSherlock } = pkg;\n```\n\nThat's it, you can now use `deviceSherlock` in your app ✨\n\n## Flags\n\nYou can use these flags to detect the device type.\n\n```js\ndeviceSherlock.isDesktop\ndeviceSherlock.isMobile\ndeviceSherlock.isTablet\ndeviceSherlock.isMobileOrTablet\ndeviceSherlock.isDesktopOrTablet\ndeviceSherlock.isIos\ndeviceSherlock.isWindows\ndeviceSherlock.isMacOS\ndeviceSherlock.isApple\ndeviceSherlock.isAndroid\ndeviceSherlock.isFirefox\ndeviceSherlock.isEdge\ndeviceSherlock.isChrome\ndeviceSherlock.isSafari\ndeviceSherlock.isSamsung\ndeviceSherlock.isCrawler\ndeviceSherlock.isUnknown\ndeviceSherlock.isCloudFront\ndeviceSherlock.isCloudflare\ndeviceSherlock.userAgent\n```\n\nThe user agent is also injected an accessible with `deviceSherlock.userAgent`.\n\n## Settings\n\nYou can set the user agent manually.\n\n```ts\ndeviceSherlock.setUserAgent('Mozilla/5.0 (Linux; Android 10; SM-G960U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.181 Mobile Safari/537.36');\n```\n\nYou can define headers manually.\n\n```ts\ndeviceSherlock.setHeaders({\n  'CF-Device-Type': 'mobile',\n  'CloudFront-Is-Mobile-Viewer': 'true',\n  'CloudFront-Is-Tablet-Viewer': 'false',\n  'CloudFront-Is-Desktop-Viewer': 'false',\n  'CloudFront-Is-Ios-Viewer': 'false',\n  'CloudFront-Is-Android-Viewer': 'true',\n});\n```\n\n## Usage\n\n### Vue, React, Angular\n\nYou can use deviceSherlock inside a `script` to access the flags.\n\n```js\n\u003cscript setup\u003e\nimport { deviceSherlock } from 'device-sherlock'\n```\n\n```js\nimport pkg from 'device-sherlock';\nconst { deviceSherlock } = pkg;\n\u003c/script\u003e\n```\n\n### Switch a view\n\n```html\n\u003ctemplate\u003e\n  \u003csection\u003e\n    \u003cdiv v-if=\"deviceSherlock.isDesktop\"\u003e\n      Desktop\n    \u003c/div\u003e\n    \u003cdiv v-else-if=\"deviceSherlock.isTablet\"\u003e\n      Tablet\n    \u003c/div\u003e\n    \u003cdiv v-else\u003e\n      Mobile\n    \u003c/div\u003e\n  \u003c/section\u003e\n\u003c/template\u003e\n```\n\n## CloudFront Support\n\nIf the `user-agent` is `Amazon CloudFront`, this module checks the following headers:\n\n- `CloudFront-Is-Mobile-Viewer`\n- `CloudFront-Is-Tablet-Viewer`\n- `CloudFront-Is-Desktop-Viewer`\n- `CloudFront-Is-Ios-Viewer`\n- `CloudFront-Is-Android-Viewer`\n\nHere are the details about the headers: [Amazon CloudFront - Headers for determining the viewer's device type](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-cloudfront-headers.html#cloudfront-headers-device-type).\n\n### Caution\n\n`isWindows`, `isLinux` and `isMacOS` flags are not available with CloudFront.\n\n## Cloudflare Support\n\nThis module checks the header `CF-Device-Type`.\n\nHere are the [details about the header](https://support.cloudflare.com/hc/en-us/articles/229373388-Cache-Content-by-Device-Type-Mobile-Tablet-Desktop-).\n\n## License\n\n[CORE](LICENSE)\n\n## Data Source\n\nThis module uses [crawler-user-agents](https://github.com/monperrus/crawler-user-agents) to generate the regular expression that detect a crawler.\n\n## Note\n\nThis module inspired by [@healerlab/device-js](https://github.com/healerlab/device-js) module.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frastislavcore%2Fdevice-sherlock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frastislavcore%2Fdevice-sherlock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frastislavcore%2Fdevice-sherlock/lists"}