Skip to main content

browser-common

CI npm version npm downloads Bundle size License: MIT

Small, tree-shakeable TypeScript wrappers around 49 browser Web APIs — each one a separate subpath export.

  • Per-API subpath imports — import { copyToClipboard } from '@rtorcato/browser-common/clipboard'. Bundlers tree-shake to just the bytes you use (under 1 kB brotlied per module, enforced by size-limit).
  • Safe-by-default contract — every module exports is<Name>Available(). Operations return null/false/empty on unsupported environments; they never throw. Safe to import in SSR / Node.
  • No runtime dependencies — ESM-only, sideEffects: false, fully typed. Nothing to install but the package itself.
  • 49 modules covered — clipboard, geolocation, media devices, observers, storage, fullscreen, notifications, service workers, and 41 more.

Browser floor​

The bundle itself needs Chrome 80, Edge 80, Firefox 74, Safari 13.1 and iOS Safari 13.4 or newer: it ships untranspiled ES2020 ESM. That is separate from what each Web API needs; see Browser support and the table on each module page.

Quick example​

import { isClipboardApiAvailable, copyToClipboard } from '@rtorcato/browser-common/clipboard'

if (isClipboardApiAvailable()) {
const ok = await copyToClipboard('hello world')
console.log(ok) // true on success, false otherwise
}

Start with Installation, read the contract that every module follows, or browse the full API Reference generated from the source.