platform_lite
v1.0.2
Published
A lightweight, zero-dependency JavaScript utility library to detect the user's **platform**, **OS**, **browser**, **touch support**, and **device type** (mobile/tablet/desktop). Designed to be small, fast, and reliable across modern browsers.
Readme
PLATFORM_LITE
A lightweight, zero-dependency JavaScript utility library to detect the user's platform, OS, browser, touch support, and device type (mobile/tablet/desktop).
Designed to be small, fast, and reliable across modern browsers.
✨ Features
- Detects operating systems:
- macOS, Windows, Linux, Android, iOS
- Detects browsers:
- Chrome, Edge, Safari, Firefox, Opera, Unknown
- Detects environment:
isMobile(),isTablet(),isDesktop()isTouch()
- Uses User-Agent Client Hints (
navigator.userAgentData) when available - Falls back to
userAgent+ platform heuristics for maximum compatibility - Zero dependencies, works in all major browsers
📦 Installation
- npm install platform_lite or
- yarn add platform_lite
🚀 Usage
import {
isMac,
isWindows,
isLinux,
isAndroid,
isIOS,
isMobile,
isTablet,
isDesktop,
isTouch,
getBrowser,
getOS
} from "platform_lite";
console.log(getOS()); // "macOS" | "Windows" | "Linux" | "Android" | "iOS" | "Unknown"
console.log(getBrowser()); // "Chrome" | "Firefox" | "Safari" ...
console.log(isMobile()); // true/false
console.log(isTouch()); // true/false