user-agent-detect
v1.1.0
Published
[](https://www.npmjs.com/package/user-agent-detector) [](LICENSE) [.
- Extract the browser version.
- Determine the device manufacturer (Samsung, Apple, Huawei, Sony, LG).
- Simple React hook for easy integration in React applications.
Installation
You can install the library via npm:
npm install user-agent-detector
Usage
REACT
import React from 'react';
import { useDeviceDetection } from 'user-agent-detect';
const App: React.FC = () => {
const deviceInfo = useDeviceDetection();
return (
<div>
<h1>Device Information</h1>
<p>Is Mobile: {deviceInfo.isMobile.toString()}</p>
<p>Is Tablet: {deviceInfo.isTablet.toString()}</p>
<p>Is Phone: {deviceInfo.isPhone.toString()}</p>
<p>OS: {deviceInfo.os}</p>
<p>Version: {deviceInfo.version}</p>
<p>Manufacturer: {deviceInfo.manufacturer}</p>
<p>Grade: {deviceInfo.grade}</p>
</div>
);
};General
<script src="https://cdn.jsdelivr.net/npm/user-agent-detect@latest/dist/index.min.js"></script>
<script>
const md = new UserAgentDetect(window.navigator.userAgent);
console.log('Is Mobile:', md.isMobile());
console.log('Is Tablet:', md.isTablet());
console.log('Is Phone:', md.isPhone());
console.log('OS:', md.os());
console.log('Version:', md.version());
console.log('Manufacturer:', md.manufacturer());
console.log('Grade:', md.grade());
</script>
These changes correct the import path and ensure that the example usage is consistent with the package's actual functionality.
