npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@eternalscloud/user-agent

v0.1.0

Published

A user agent request is a string of text that identifies the client software requesting online content.

Readme

@eternalscloud/user-agent

npm version npm downloads License: MIT

A powerful user agent parser library from Eternals Cloud for identifying client software, browsers, devices, and operating systems from HTTP user agent strings.

✨ Features

  • 🔍 Comprehensive Parsing - Extract browser, device, OS, and platform information
  • 📱 Device Detection - Identify mobile, tablet, and desktop devices
  • 🌐 Cross-Platform - Works with all major browsers and operating systems
  • Lightweight - Minimal dependencies and fast parsing
  • 📦 TypeScript Ready - Full TypeScript support with type definitions
  • 🚀 Zero Dependencies - Uses only essential parsing logic
  • 📦 Package Size - 15KB (45KB unpacked)

📦 Installation

npm install @eternalscloud/user-agent
yarn add @eternalscloud/user-agent
pnpm add @eternalscloud/user-agent

🚀 Quick Start

// 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);

📚 API Reference

userAgent Function

Function Signature

userAgent(userAgentString: string): ParsedUserAgent

Parameters

| Parameter | Type | Description | |-----------|------|-------------| | userAgentString | string | The user agent string to parse |

Return Object Structure

{
  "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"
}

Return Object Properties

| 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" |

💡 Usage Examples

Basic Parsing

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}`);

Express.js Integration

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
  });
});

React/Next.js

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>
  );
}

TypeScript Usage

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}`);
}

🌐 Supported Browsers & Devices

Browsers

  • ✅ Chrome, Firefox, Safari, Edge
  • ✅ Internet Explorer (all versions)
  • ✅ Mobile browsers (Chrome Mobile, Safari Mobile, etc.)
  • ✅ Bot and crawler detection

Operating Systems

  • ✅ Windows (all versions)
  • ✅ macOS (all versions)
  • ✅ Linux distributions
  • ✅ iOS and Android
  • ✅ Other mobile platforms

Device Types

  • ✅ Desktop computers
  • ✅ Mobile phones
  • ✅ Tablets
  • ✅ Smart TVs and other devices

📄 License

  • Package: MIT License
  • Source Code: MIT License

License Summary

  • ✅ Free for commercial and personal use
  • ✅ Can be used in proprietary software
  • ✅ Can be modified and redistributed
  • ✅ No attribution required (but appreciated)