# @bonsai-components/detect-os

> Make detecting user's OS less annoying

Latest version **0.1.8** (published 2025-03-04) · (MIT OR Apache-2.0) license · 0 weekly downloads

## Install

```sh
npm install @bonsai-components/detect-os
pnpm add @bonsai-components/detect-os
yarn add @bonsai-components/detect-os
bun add @bonsai-components/detect-os
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.8 |
| Published | 2025-03-04 |
| First published | 2023-03-14 |
| Weekly downloads | 0 |
| License | (MIT OR Apache-2.0) |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Kyle Scully |
| Maintainers | zieka, sjungling |
| Keywords | meta, os, detect, operating, system, detection, cross-browser, cross-platform |

## Links

- npm: https://www.npmjs.com/package/@bonsai-components/detect-os
- npm.io page: https://npm.io/package/@bonsai-components/detect-os

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 0.1.8 (latest) — 2025-03-04
- 0.1.7 — 2025-03-04
- 0.1.1 — 2023-03-14
- 0.3.0 — 2023-03-14

## README

<p align="center"><img src="https://raw.githubusercontent.com/zieka/bonsai-components/main/svg/bonsai-logo.svg" height="250px" alt="Bonsai Logo"></p>

# Detect OS

## Intro

This package aims to make detection of the user's operating system easy.

## How to install

```
npm i @bonsai-components/detect-os
```

## How to use

There are 3 different variants:

- `detectOSInBrowser` - handles detection in the browser
- `detectOSInNodeProcess` - handles detection in node
- `detectOS` - universal detection (the most code delivered but handles universal usage)

All variants work the same way `() => 'mac' | 'windows' | 'other'`. There is a `const enum` for typescript users to take advantage of as well.

Common usage:

```ts
import { detectOS } from '@bonsai-components/detect-os';

switch (detectOS()) {
  case 'mac':
    // do something
    break;
  case 'windows':
    // do something
    break;
  case 'other':
    // do something
    break;
}
```

---
_Source: https://npm.io/package/@bonsai-components/detect-os · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
