browser-common
Small, tree-shakeable TypeScript wrappers around 52 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 — most modules export
is<Name>Available()for feature detection. Operations returnnull/false/empty on unsupported environments; they don't throw for missing APIs (except alert, canvas, and observers, which may throw — wrap those intry/catch). Safe to import in SSR / Node. - No runtime dependencies — ESM-only,
sideEffects: false, fully typed. Nothing to install but the package itself. - 52 modules covered — clipboard, geolocation, media devices, observers, storage, fullscreen, notifications, service workers, and 44 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.