device-detector-js is a robust JavaScript/TypeScript library designed for precise user agent parsing and device detection. It identifies the browser, operating system, device type (desktop, mobile, tablet, TV, etc.), brand, and model from any user agent string. As a JavaScript port of Matomo's highly regarded `device-detector` library (specifically version 4.2.3), it benefits from an extensive and regularly updated open-source user agent database. The current stable version is 3.0.3, and its release cadence is likely tied to updates from the upstream Matomo project to maintain accuracy and coverage. Key differentiators include its lack of external dependencies, comprehensive TypeScript support, and a rigorous testing suite comprising over 10,000 user agent strings. While it functions in both Node.js and browser environments, the library strongly advises against browser-side usage for performance-critical applications due to its size and processing overhead.
npm install device-detector-jsVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to initialize the DeviceDetector and parse a common user agent string, logging the structured client, OS, and device details.
For performance-critical applications, prefer server-side user agent detection (e.g., in Node.js). If browser-side usage is unavoidable, ensure thorough performance testing and consider alternative, lighter-weight libraries if appropriate.
For ESM and modern TypeScript, ensure you are using the default import: `import DeviceDetector from 'device-detector-js';`. If using CommonJS in JavaScript, the pattern `const DeviceDetector = require('device-detector-js');` should work, assuming the CommonJS export directly exposes the class. In older TypeScript with CommonJS, follow the documentation's suggestion: `import DeviceDetector = require('device-detector-js');`.Always use the full, explicit path for sub-modules: `import BotDetector from 'device-detector-js/dist/parsers/bot';`.
No dependency data recorded yet.