---
url: https://undevice.hacks.run/index.md
---

# undevice

Unified Device Detector

Device, OS, and browser detection from headers. Dependency-free, typed, and ready for CDN signals.

- [Get started](/guide/getting-started)
- [Try it live](/playground)
- [Adapters](/adapters/)
- [GitHub](https://github.com/teplostanski/undevice)

## Any runtime

Node.js, browser, or edge. You supply the input; undevice returns the flags.

## Custom flags

Add your own device detection flags with automatic type inference.

## CDN-aware

Cloudflare and CloudFront hints with explicit precedence over User-Agent.

## Adapters

Ready-to-use Express middleware and Fastify plugin with typed flags in route handlers.

[Explore adapters](/adapters/)


::: code-group

```ts twoslash [Basic usage]
import { undevice } from 'undevice'

const { detect } = undevice()
const device = detect({ userAgent: navigator.userAgent })

device.isMobile
device.isDesktop
device.isWindows
device.isChrome
```

```ts twoslash [Custom flags]
// This example uses the third-party library isbot
import { isbot } from 'isbot'
import { undevice } from 'undevice'

// Configure custom flags
const { detect } = undevice({
  isCrawler: isbot,
  isRawClient: ['curl', 'wget'],
})
const device = detect({ userAgent: navigator.userAgent })

device.isMobile
device.isDesktop
device.isWindows
device.isChrome

// Use custom flags
device.isCrawler
device.isRawClient
```

:::
