Skip to main content
v2Now strict TypeScript, dual ESM + CJS, 1.4 kB

The browser detector that
actually fits in a tweet.

get-browser answers which browser? with a strict TypeScript union. 1.4 kB min+gzip. Zero runtime dependencies. Works in Node, the browser, edge runtimes, Workers, Deno — same import, same call.

$ pnpm add get-browseror npm · yarn · bun
~1.4 kBmin+gzip
0dependencies
168tests · 98% cov
8browser families
detect.ts
import { detect, browsers } from 'get-browser';

const browser = detect();
// ^? Browser = 'chrome' | 'edge' | 'firefox' | ...

if (browser === browsers.SAFARI) {
patchSafariScrollBug();
}
output
→ 'chrome'
BUILT FOR

First-class support for every framework you ship with

The library is platform-neutral — same imports, same call shape — and ships dedicated recipes for the runtimes and frameworks you actually use.

TRY IT LIVE

This card is reading your actual user-agent

Pick a sample UA from the dropdown, paste your own, or leave both empty to detect against your real navigator.userAgent. The code path is exactly the one your app would run.

  • detect() returns one of browsers.*
  • Predicates like isSafari() return a strict boolean
  • Pass an explicit UA for SSR / unit-test scenarios
  • The LIVE dot says where the UA is coming from
Open the full playground →
Loading detection…

Why get-browser?

User-agent sniffing is a pile of caveats, but sometimes you really do need it — to gate a polyfill, render a download badge, or tag analytics. get-browser is the small, opinionated utility for those cases.

Tiny by design

~1.5 kB min+gzip, zero runtime dependencies, fully tree-shakeable. Importing only isChrome ships nothing else.

Strict TypeScript

detect() returns the Browser union — never plain string. Exhaustive switch statements compile.

SSR-safe

Every detector takes an optional { userAgent, vendor }. No window access at import time — runs in Node, Next.js, Remix, Astro, and tests.

Covers what ships

Chrome, Edge (legacy + Chromium), Firefox, Safari (macOS / iOS / iPadOS), Opera (Presto + OPR), IE 6–11, Android WebView — including CriOS, FxiOS,EdgiOS.

Dual ESM + CJS

import and require both work. UMD/IIFE bundle (GetBrowser global) ships for <script> tags.

Honest scope

Answers who, not what. For capability gating, use @supports or matchMedia. We only do the part those can't.

USE CASES

The narrow set of times you actually need UA sniffing

Most of the time, feature detection is the right answer. These are the cases where it isn't.

BUNDLE SIZE

How it stacks up against the alternatives

get-browser trades version-parsing and device-info for a fraction of the footprint. If your job is "tell me which browser, then get out of my way," this is your library.

Sizes are min+gzip of the full library bundle. get-browser also tree-shakes down to ~400 bytes when you import a single predicate.

See full feature comparison →

READY?

Install in one line. Ship in the next.

get-browser is what you reach for when you just want a single, lowercase, typed answer to which browser is this?

$ pnpm add get-browser