# matthewhudson/current-device

📱 The easiest way to write conditional CSS and/or JavaScript based on device operating system (iOS, Android, Blackberry, Windows, Firefox OS, MeeGo), orientation (Portrait vs. Landscape), and type (Tablet vs. Mobile).

Repository: https://github.com/matthewhudson/current-device
Canonical: https://ross.abutalabs.com/products/current-device
Homepage: https://matthewhudson.github.io/current-device/
Language: TypeScript
License: MIT
License Family: permissive
Topics: device-detection, javascript, mobile
Last push: 2026-06-08T23:55:23+00:00

## Health v2 (maintenance only)
Score: 84/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 86, release rhythm 72, longevity 100
- inputs: {"age_days": 5096, "days_push": 86, "days_rel": 189, "gap_med": 0, "n_releases_24m": 2}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 3927, forks 576 (observed 2026-08-28T04:08:29.910752+00:00)

## What it is
A lightweight JavaScript/TypeScript library that detects the device's operating system, type (mobile/tablet/desktop), and orientation, exposing a simple JS API and automatically adding conditional CSS classes to the <html> element. It supports iOS, Android, Blackberry, Windows, macOS, Firefox OS, MeeGo, and more.

## Use cases
- detect if user is on mobile or tablet in javascript
- apply conditional css based on device operating system
- detect portrait vs landscape orientation in browser
- add device-specific css classes to html element
- serve different styles for ios vs android
- run mobile-specific javascript logic
- detect device type in typescript

## When to choose
- you need simple client-side device detection with zero configuration
- you want both a JavaScript API and automatic CSS classes from one small library
- you need orientation change callbacks for responsive behavior
- you want TypeScript types included out of the box

## When to avoid
- you need server-side or user-agent-string-based detection with detailed device metadata
- you only need responsive layouts, which CSS media queries handle natively
- you require feature detection rather than device detection
- you need detection of specific browsers or browser versions

## Facets
- artifact type: library
- maturity: active
- function: ui-components, developer-tools
- domain: web-development, frontend, mobile-development
- platform: browser
- tags: device-detection, css-classes, responsive-design, user-agent, mobile-web, typescript, javascript, nodejs

## Member repositories
- matthewhudson/current-device (main) score 84

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:08:29.910752+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T18:24:42.648486+00:00, confidence not recorded.
  - readme: https://github.com/matthewhudson/current-device (fetched 2026-08-28T04:08:29.910752+00:00, sha 4bcb1ae2efee)
  - homepage: https://matthewhudson.github.io/current-device/ (fetched 2026-08-29T09:18:50.399783+00:00, sha b0aadf60acf1)
  - registry_npm: https://registry.npmjs.org/current-device (fetched 2026-08-29T09:18:50.409155+00:00, sha 864117ea8567)
- Data as of 2026-08-30T08:39:29.467469+00:00.
