
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
@eternalscloud/user-agent
Advanced tools
A user agent request is a string of text that identifies the client software requesting online content.
A powerful user agent parser library from Eternals Cloud for identifying client software, browsers, devices, and operating systems from HTTP user agent strings.
npm install @eternalscloud/user-agent
yarn add @eternalscloud/user-agent
pnpm add @eternalscloud/user-agent
// ES6 Modules
import { userAgent } from "@eternalscloud/user-agent";
// CommonJS
const { userAgent } = require("@eternalscloud/user-agent");
// Parse a user agent string
import { userAgent } from "@eternalscloud/user-agent";
const result = userAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36");
console.log(result);
userAgent(userAgentString: string): ParsedUserAgent
Parameter | Type | Description |
---|---|---|
userAgentString | string | The user agent string to parse |
{
"browser": "Chrome",
"version": "119.0.0.0",
"os": "Windows 10.0",
"platform": "Microsoft Windows",
"source": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
"device_type": "web"
}
Property | Type | Description |
---|---|---|
browser | string | Browser name (Chrome, Firefox, Safari, etc.) |
version | string | Browser version |
os | string | Operating system name and version |
platform | string | Platform information |
source | string | Original user agent string |
device_type | string | Device type: "mobile", "tab", or "web" |
import { userAgent } from "@eternalscloud/user-agent";
const parsed = userAgent(req.headers['user-agent']);
console.log(`Browser: ${parsed.browser} ${parsed.version}`);
console.log(`Device: ${parsed.device_type}`);
console.log(`OS: ${parsed.os}`);
import express from 'express';
import { userAgent } from "@eternalscloud/user-agent";
const app = express();
app.get('/', (req, res) => {
const deviceInfo = userAgent(req.headers['user-agent']);
res.json({
message: 'Hello World',
device: deviceInfo
});
});
import { userAgent } from "@eternalscloud/user-agent";
function MyComponent() {
const [deviceInfo, setDeviceInfo] = useState(null);
useEffect(() => {
const parsed = userAgent(navigator.userAgent);
setDeviceInfo(parsed);
}, []);
return (
<div>
{deviceInfo && (
<p>You're using {deviceInfo.browser} on {deviceInfo.os}</p>
)}
</div>
);
}
import { userAgent } from "@eternalscloud/user-agent";
const result = userAgent("Mozilla/5.0...");
// Type-safe access to properties
if (result.browser === 'Chrome') {
console.log(`Chrome version: ${result.version}`);
}
FAQs
A user agent request is a string of text that identifies the client software requesting online content.
The npm package @eternalscloud/user-agent receives a total of 9 weekly downloads. As such, @eternalscloud/user-agent popularity was classified as not popular.
We found that @eternalscloud/user-agent demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.