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
- Checks browser name, version and rendering engine from user-agent strings
- Detects device type (phone, tablet, desktop) and manufacturer details
- Gets operating system name and version with a single function call
- Extracts CPU architecture and device model information cleanly
- Returns parsed results in a simple JSON format for easy code integration