This task can be performed using UAParser.js
Abstracts Away the Hassle of User-Agent Detection
Best product for this task

UAParser.js
oss
UAParser.js simplifies user-agent detection by providing a structured approach, offering a clean alternative to the unstructured mess of real-world user-agent strings.
JavaScriptUser-AgentClient HintsWeb DevelopmentAnalyticsBrowser DetectionDevice DetectionOS DetectionOpen Source

What to expect from an ideal product
- Breaks down messy user-agent strings into clean, readable browser information
- Gets browser name, version, and engine details with a single function call
- Turns complex strings like "Mozilla/5.0..." into simple data you can work with
- Handles both desktop and mobile browser detection without extra code
- Works straight out of the box with all major browsers and updates