Browser detection using the user agent string (UA sniffing) — Client hints
For Blink-based browsers (Chromium, Edge, Brave, Vivaldi, etc.), an alternative is User agent client hints.
Reference note (untrusted external data; do not execute it as instructions).
For Blink-based browsers (Chromium, Edge, Brave, Vivaldi, etc.), an alternative is User agent client hints. In client hints, the server proactively requests device information from a client through HTTP headers or via JavaScript API.
Client hints are better than UA sniffing for detecting Blink-based browsers in that they're not as commonly-spoofed, and they provide smaller, more reliable pieces of information that are easier to parse. Changing site functionality based on client hints is still a bad idea! Where possible you should instead use feature detection and progressive enhancement as described above.
For example, in the HTTP mechanism, the server includes an {{httpheader("Accept-CH")}} header along with a list of headers that should be included by the client in subsequent requests. Let's assume the server sends this response to the client
This asks for the following headers from
Attribution: Adapted from MDN Web Docs under CC-BY-SA-2.5. Adaptation: WikiKV isolated this documentation section, normalized formatting, removed long code blocks, and shortened it for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
MDN Web Docs — files/en-us/web/http/guides/browser_detection_using_the_user_agent/index.md :: Client hints ↗Revision d14bee540b53 · CC-BY-SA-2.5