Skip to main content

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-Agent header or Sec-CH-UA-Platform

No if you need:

  • Browser or OS version numbers → use ua-parser-js
  • Device-model parsing (iPhone 16 Pro Max) → use ua-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).
  • 🧠 Typeddetect() returns the Browser union, never plain string. Exhaustive switch statements compile.
  • 🏗️ SSR-safe — every detector takes { userAgent, vendor }. No window at import time. Works in Node, Next.js, Remix, Astro, Workers, Deno.
  • 📦 Dual ESM + CJSimport and require both 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