Introduction
get-browser answers two questions: which browser is this, and which OS is it on?
import { detect, getOS, browsers, oses } from 'get-browser';
detect(); // → 'chrome' | 'edge' | 'firefox' | ...
getOS(); // → 'macos' | 'windows' | 'linux' | 'ios' | 'android' | 'chromeos' | 'unknown'
detect() === browsers.SAFARI; // → true on Safari (with the constant type-checked)
getOS() === oses.MACOS; // → true on macOS — show ⌘ K instead of Ctrl K
That's the whole pitch. ~1.4 kB min+gzip, zero dependencies, dual ESM + CJS, strict TypeScript types, and an SSR-safe API. It pairs detect() and getOS() with a handful of single-purpose predicates (isChrome, isMobile, …) when all you want is a boolean.
Should I use this?
Yes if you need a small, typed, who-is-this? check for:
- 🔧 Working around a known browser bug
- 📦 Loading a polyfill only when needed
- 📊 Tagging analytics with browser family / engine
- 🖼️ Rendering a "Download for your browser" / "Download for your OS" badge
- ⌘ Picking the right keyboard shortcut for the current OS
- 🛍️ Linking to the right App Store / Play Store
- 🚪 Bouncing users out of Instagram / TikTok / Facebook in-app browsers before OAuth
- 🏗️ Server-side branching on the request
User-Agentheader orSec-CH-UA-Platform
No if you need:
- Browser or OS version numbers → use
ua-parser-js - Device-model parsing (
iPhone 16 Pro Max) → useua-parser-js - A feature check ("does this browser support X?") → use
@supports,matchMedia, or capability probes
See feature detection vs UA sniffing for the longer story.
What you get
- 🪶 Tiny — ~1.4 kB min+gzip, zero dependencies, fully tree-shakeable (single predicates ship at ~400 bytes).
- 🧠 Typed —
detect()returns theBrowserunion, never plainstring. Exhaustiveswitchstatements compile. - 🏗️ SSR-safe — every detector takes
{ userAgent, vendor }. Nowindowat import time. Works in Node, Next.js, Remix, Astro, Workers, Deno. - 📦 Dual ESM + CJS —
importandrequireboth work, types ship for both. UMD bundle for<script>tags.
See it without installing
The Playground runs get-browser against your real navigator.userAgent (or any UA string you paste). Best way to see the API in 30 seconds.
Next steps
- 🚀 Install — pnpm / npm / yarn / bun, or CDN.
- ⚡ Quickstart — the 10-line tour.
- 🔌 API reference — every export, with examples.
- 🍳 Recipes — copy-paste patterns for common tasks.
- 🌐 Browser support — exactly which UAs the library recognizes.
- 🔄 v1 → v2 migration — what changed.