https://github.com/xulww/get-os-name
A simple and small npm package that gives you the operating system name of a client
https://github.com/xulww/get-os-name
android browser detect ios javascript js linux macos name navigator navigator-api no-dependencies npm npm-package operating-system os package unix web windows
Last synced: about 1 month ago
JSON representation
A simple and small npm package that gives you the operating system name of a client
- Host: GitHub
- URL: https://github.com/xulww/get-os-name
- Owner: xulww
- License: mit
- Created: 2022-12-20T09:21:17.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-03T14:32:59.000Z (over 2 years ago)
- Last Synced: 2025-05-06T18:02:13.114Z (about 2 months ago)
- Topics: android, browser, detect, ios, javascript, js, linux, macos, name, navigator, navigator-api, no-dependencies, npm, npm-package, operating-system, os, package, unix, web, windows
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/get-os-name
- Size: 14.6 KB
- Stars: 8
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# get-os-name
This is a very simple and small npm package that gives you the operating system name of a client. It has **no dependencies** and uses JavaScript and the
Navigator Web API, which has [wide browser support](https://caniuse.com/mdn-api_navigator).## Installation
```
npm install get-os-name
```## Important
To be more specific, this package uses [navigator.userAgent](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgent). Keep in mind that browser users can change
the value of this field if they want (UA spoofing).## Exports
| Function name | Return type | Description |
| --------------------------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| getOperatingSystemName | string | The default package export. A function that returns the name of the operating system (e.g. "Windows"). Fallbacks to "Unknown". |
| isUNIX | boolean | A function that returns true if the operating system is UNIX |
| isWindows | boolean | A function that returns true if the operating system is Windows |
| isMacOS | boolean | A function that returns true if the operating system is macOS |
| isLinux | boolean | A function that returns true if the operating system is Linux |
| isAndroid | boolean | A function that returns true if the operating system is Android |
| isIOS | boolean | A function that returns true if the operating system is iOS |## Usage
```javascript
import getOperatingSystemName, {
isUNIX,
isWindows,
isMacOS,
isLinux,
isAndroid,
isIOS,
} from "get-os-name";const osName = getOperatingSystemName()
const isOSNameUNIX = isUNIX()
const isOSNameWindows = isWindows()
const isOSNameMacOS = isMacOS()
const isOSNameLinux = isLinux()
const isOSNameAndroid = isAndroid()
const isOSNameIOS = isIOS()
```
[Demo](https://codesandbox.io/s/get-os-name-example-6ccr13)