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 🙏

© 2025 – Pkg Stats / Ryan Hefner

device-uuid

v2.0.0

Published

Fast browser device uuid generation library.

Readme

device-uuid

Fast browser device UUID generation library with comprehensive device detection. Written in TypeScript with zero dependencies, supporting both Node.js and browser environments.

Features

  • 🚀 Zero dependencies
  • 📦 Multiple module formats (ESM, CJS, IIFE)
  • 🔍 Comprehensive device detection (OS, browser, platform)
  • 📱 Mobile, tablet, and desktop detection
  • 🤖 Bot detection
  • 📺 Smart TV detection
  • 🎨 TypeScript support with full type definitions
  • 🌐 Browser and Node.js compatible

Installation

npm install device-uuid

Usage

Node.js / Module Bundlers

// ES Modules
import { DeviceUUID } from 'device-uuid';

// CommonJS
const { DeviceUUID } = require('device-uuid');

// Generate UUID
const device = new DeviceUUID();
const uuid = device.get();
console.log(uuid); // e9dc90ac-d03d-4f01-a7bb-873e14556d8e

// Get device information
const info = device.parse();
console.log(info.browser); // Chrome
console.log(info.os); // Windows 11
console.log(info.isMobile); // false

Browser (via CDN or direct include)

<!-- Minified version (recommended for production) -->
<script src="node_modules/device-uuid/dist/index.browser.min.js"></script>

<!-- Or unminified for development -->
<script src="node_modules/device-uuid/dist/index.browser.js"></script>

<script>
  // Create instance
  const device = new DeviceUUID.DeviceUUID();

  // Generate UUID
  const uuid = device.get();
  console.log('Device UUID:', uuid);

  // Parse user agent
  const info = device.parse();
  console.log('Browser:', info.browser);
  console.log('OS:', info.os);
  console.log('Is Mobile:', info.isMobile);
</script>

Advanced Usage

Custom UUID Generation

const device = new DeviceUUID();
const info = device.parse();

// Create custom UUID from specific properties
const customData = [
  info.language,
  info.platform,
  info.os,
  info.cpuCores,
  info.isAuthoritative,
  info.silkAccelerated,
  info.isKindleFire,
  info.isDesktop,
  info.isMobile,
  info.isTablet,
  info.isWindows,
  info.isLinux,
  info.isLinux64,
  info.isMac,
  info.isiPad,
  info.isiPhone,
  info.isiPod,
  info.isSmartTV,
  info.pixelDepth,
  info.isTouchScreen,
].join(':');

const customUUID = info.hashMD5(customData);

Parse Custom User Agent String

const device = new DeviceUUID();
const customUA = 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_2 like Mac OS X) AppleWebKit/605.1.15';
const info = device.parse(customUA);

console.log(info.isiPhone); // true
console.log(info.os); // iOS

API Reference

DeviceUUID

Methods

  • get(customData?: string): string - Generate a UUID based on device characteristics
  • parse(source?: string): AgentInfo - Parse user agent string and return device information
  • reset(): this - Reset the device information to default values

AgentInfo Interface

The parse() method returns an object with the following properties:

Device Type Flags

  • isDesktop: boolean - Desktop computer
  • isMobile: boolean - Mobile phone
  • isTablet: boolean - Tablet device
  • isBot: boolean | string - Bot/crawler detection
  • isSmartTV: boolean - Smart TV device
  • isTouchScreen: boolean - Touch screen support

Browser Information

  • browser: string - Browser name (Chrome, Firefox, Safari, Edge, etc.)
  • version: string - Browser version
  • isChrome: boolean
  • isFirefox: boolean
  • isSafari: boolean
  • isEdge: boolean
  • isOpera: boolean
  • isIE: boolean

Operating System

  • os: string - Operating system name and version
  • isWindows: boolean
  • isMac: boolean
  • isLinux: boolean
  • isLinux64: boolean
  • isChromeOS: boolean

Mobile Platforms

  • isAndroid: boolean
  • isAndroidTablet: boolean
  • isiPhone: boolean
  • isiPad: boolean
  • isiPod: boolean
  • isSamsung: boolean
  • isBlackberry: boolean

Device Properties

  • platform: string - Platform name
  • language: string - Browser language
  • colorDepth: number - Screen color depth
  • pixelDepth: number - Screen pixel depth
  • resolution: [number, number] - Screen resolution [width, height]
  • cpuCores: number - Number of CPU cores
  • source: string - Original user agent string

Utility Functions

  • hashMD5(value: string): string - Generate MD5 hash
  • hashInt(value: string): number - Generate integer hash

Supported Detection

Operating Systems

  • Windows (7, 8, 8.1, 10, 11)
  • macOS (all versions including Catalina, Big Sur, Monterey, Ventura, Sonoma, Sequoia)
  • Linux (including Ubuntu and other distributions)
  • iOS
  • Android
  • Chrome OS
  • Windows Phone

Browsers

  • Chrome / Chromium
  • Firefox
  • Safari
  • Edge (Chromium and Legacy)
  • Opera
  • Internet Explorer
  • PhantomJS
  • UC Browser
  • And many more

Device Types

  • Desktop computers
  • Mobile phones
  • Tablets
  • Smart TVs (Samsung, LG, Apple TV)
  • Kindle Fire devices
  • Bots and crawlers (Google, Bing, Yandex, etc.)

Bundle Sizes

  • ESM: ~31 KB (unminified)
  • CJS: ~31 KB (unminified)
  • Browser (IIFE): ~34 KB (unminified), ~19 KB (minified)

Example Output

{
  "isMobile": false,
  "isDesktop": true,
  "isBot": false,
  "isTablet": false,
  "isiPad": false,
  "isiPhone": false,
  "isAndroid": false,
  "isBlackberry": false,
  "isOpera": false,
  "isIE": false,
  "isEdge": false,
  "isChrome": true,
  "isFirefox": false,
  "isSafari": false,
  "isWindows": true,
  "isMac": false,
  "isLinux": false,
  "browser": "Chrome",
  "version": "120.0.0.0",
  "os": "Windows 11",
  "platform": "Microsoft Windows",
  "language": "en-US",
  "colorDepth": 24,
  "pixelDepth": 24,
  "resolution": [1920, 1080],
  "cpuCores": 8,
  "source": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36...",
  "hashMD5": [Function],
  "hashInt": [Function]
}

LICENSE

MIT © Aleksejs Gordejevs and contributors.