{"id":15853164,"url":"https://github.com/omrilotan/client-hints","last_synced_at":"2025-03-15T21:30:55.560Z","repository":{"id":55052797,"uuid":"467177184","full_name":"omrilotan/client-hints","owner":"omrilotan","description":"🕵️‍♂️ Parse client hints headers","archived":false,"fork":false,"pushed_at":"2025-02-06T19:33:16.000Z","size":39,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-27T04:11:27.392Z","etag":null,"topics":["client-hints","headers"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/client-hints","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/omrilotan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2022-03-07T16:41:19.000Z","updated_at":"2025-02-06T19:33:20.000Z","dependencies_parsed_at":"2024-05-02T12:52:24.570Z","dependency_job_id":"6a355535-c4ed-41bf-ad3a-f40709e9ced6","html_url":"https://github.com/omrilotan/client-hints","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omrilotan%2Fclient-hints","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omrilotan%2Fclient-hints/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omrilotan%2Fclient-hints/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omrilotan%2Fclient-hints/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omrilotan","download_url":"https://codeload.github.com/omrilotan/client-hints/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243792329,"owners_count":20348619,"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":["client-hints","headers"],"created_at":"2024-10-05T19:03:05.908Z","updated_at":"2025-03-15T21:30:55.067Z","avatar_url":"https://github.com/omrilotan.png","language":"TypeScript","readme":"# client-hints [![](https://img.shields.io/npm/v/client-hints.svg?style=flat-square)](https://www.npmjs.com/package/client-hints)\n\n🕵️‍♂️ Parse client hints headers and provide a convenient API to access device information and user preferences\n\nUse client hints, where available\n\n```js\nimport { ClientHints } from \"client-hints\";\nimport { userAgentParser } from \"some-user-agent-parser-library\";\n\napp.get(\"/api-endpoint\", (req, res) =\u003e {\n  const hints = new ClientHints(req);\n\n  const isMobile =\n    hints.mobile ?? // cheap\n    userAgentParser(req.get(\"user-agent\")).device?.type === \"mobile\"; // more expensive\n\n  const browserName =\n    hints.vendorName ?? // cheap\n    userAgentParser(req.get(\"user-agent\")).browser?.name; // more expensive\n\n  console.log(JSON.stringify(hints, null, 2)); // Serialises all available hints\n\n  res.send(`${isMobile ? \"Mobile\" : \"Desktop\"} browser: ${browserName}`);\n});\n```\n\n## Available detections\n\nAll detections return `undefined` if the relevant header is not available.\n\n| Feature                                 | Type      | Header                                                           | Meaning                                        | Adoption level |\n| --------------------------------------- | --------- | ---------------------------------------------------------------- | ---------------------------------------------- | -------------- |\n| `arch`, `architecture`                  | _string_  | Sec-CH-UA-Arch                                                   | CPU architecture                               | Experimental   |\n| `bitness`                               | _number_  | Sec-CH-UA-Bitness                                                | CPU bitness (32, 64)                           | Experimental   |\n| `contentDpr`, `contentDevicePixelRatio` | _number_  | Content-DPR                                                      | Image device pixel ratio                       | Deprecated     |\n| `deviceMemory`                          | _number_  | Device-Memory                                                    | Appr. available RAM                            | Experimental   |\n| `downlink`                              | _number_  | Downlink                                                         | Network speed (Mbps)                           | Experimental   |\n| `dpr`, `devicePixelRatio`               | _number_  | DPR                                                              | Device pixel ratio                             | Deprecated     |\n| `ect`, `effectiveConnectionType`        | _string_  | ECT                                                              | Network profile (G)                            | Experimental   |\n| `fetchDest`, `fetchDestination`         | _string_  | Sec-Fetch-Dest                                                   | Resource type                                  |\n| `fetchMode`                             | _string_  | Sec-Fetch-Mode                                                   | Navigation type                                |\n| `fetchSite`                             | _string_  | Sec-Fetch-Site                                                   | Relationship to origin                         |\n| `fetchUser`                             | _boolean_ | Sec-Fetch-User                                                   | Was the request triggered by user action       |\n| `gpc`                                   | _boolean_ | Sec-GPC                                                          | Consents to sell or share personal information | Experimental   |\n| `mobile`                                | _boolean_ | Sec-CH-UA-Mobile                                                 | Boolean: Is this a mobile device               | Experimental   |\n| `model`                                 | _string_  | Sec-CH-UA-Model                                                  | Device model                                   | Experimental   |\n| `platform`                              | _string_  | Sec-CH-UA-Platform                                               | Operating system name                          | Experimental   |\n| `platformVersion`                       | _string_  | Sec-CH-UA-Platform-Version                                       | Operating system version                       | Experimental   |\n| `prefersColorScheme`                    | _string_  | Sec-CH-Prefers-Color-Scheme                                      | User's preferred color scheme                  | Experimental   |\n| `prefersReducedMotion`                  | _boolean_ | Sec-CH-Prefers-Reduced-Motion                                    | User prefers reduced motion                    | Experimental   |\n| `prefersReducedTransparency`            | _boolean_ | Sec-CH-Prefers-Reduced-Transparency                              | User prefers reduced transparency              | Experimental   |\n| `purpose`                               | _string_  | Sec-Purpose                                                      | Resource purpose (prefetch)                    | Experimental   |\n| `vendorName`                            | _string_  | Sec-CH-UA / Sec-CH-UA-Full-Version-List                          | Browser Name                                   | Experimental   |\n| `vendorVersion`                         | _string_  | Sec-CH-UA-Full-Version / Sec-CH-UA / Sec-CH-UA-Full-Version-List | Browser version                                | Experimental   |\n| `viewportWidth`                         | _number_  | Viewport-Width                                                   | Layout viewport width                          | Deprecated     |\n| `width`                                 | _number_  | Width                                                            | Resource desired width                         | Deprecated     |\n\n## Client Hints Instructions Response Header\n\nSet the value of `Accept-CH` header to include the headers you want the browse to send.\n\n```plaintext\nAccept-CH: Sec-CH-UA-Mobile,Sec-CH-UA-Full-Version,Sec-CH-UA-Full-Version-List,Sec-CH-UA-Model,Sec-CH-UA-Platform,Sec-CH-UA-Platform-Version,ECT\n```\n\nInclude all available hints:\n\n```plaintext\nAccept-CH: *\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomrilotan%2Fclient-hints","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomrilotan%2Fclient-hints","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomrilotan%2Fclient-hints/lists"}