Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Device detection library for node.js based on the user-agent, built on top of express
| Date | Stars |
|---|---|
| 2026-07-31 | 305 |
| 2026-08-06 | 305 |
| 2026-09-09 | 303 |
| 2026-10-14 | 304 |
| 2026-11-04 | 304 |
Today
— stars today
This week
— stars this week
This month
+1 stars this month
Momentum
0.0
growth rate 0.00%/day
# express-device [](https://npmjs.org/package/express-device) [](https://npmjs.org/package/express-device) [](http://travis-ci.org/rguerreiro/express-device)
Case you're interested only on the device type detection based on the useragent string and don't need all the [express](http://expressjs.com/) related stuff, then use the `device` package ([https://www.npmjs.com/package/device](https://www.npmjs.com/package/device)) which was refactored from `express-device` for that purpose.
## why express-device?
I'm really into node.js and lately I've been playing a lot with it. One of the steps I wanted to take in my learning path was to build a node.js module and published it to npm.
Then I had an idea: why not develop a server side library to mimic the behaviour that Twitter's [Bootstrap](http://twitter.github.com/bootstrap/scaffolding.html#responsive) has in order to identify where a browser is running on a desktop, tablet or phone. This is great for a [responsive design](http://en.wikipedia.org/wiki/Responsive_Web_Design), but on the server side.
## how it came to be?
First I started to search how I could parse the user-agent string and how to differentiate tablets from smartphones. I found a couple good references, such as:
- http://www.useragentstring.com/pages/useragentstring.php
- http://detectmobilebrowsers.com/
- http://www.quirksmode.org/js/detect.html
- http://googlewebmastercentral.blogspot.pt/2011/03/mo-better-to-also-detect-mobile-user.html
- http://www.htmlgoodies.com/beyond/webmaster/toolbox/article.php/3888106/How-Can-I-Detect-the-iPhone--iPads-User-Agent.htm
- http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/08/29/introducing-the-ie9-on-windows-phone-mango-user-agent-string.aspx
But then I came across with Brett Jankord's [blog](http://www.brettjankord.com). He developed [Categorizr](http://www.brettjankord.com/2012/01/16/categorizr-a-modern-device-detection-script/) which is what I was trying to do for node.js but for PHP. He has the code hosted at [Github](https://github.com/bjankord/Categorizr). So, express-device parsing methods (to extract device type) are based on Categorizr. Also I've used all of his [user-agent strings compilation](http://brettjankord.com/categorizr/categorizr-results.php) to build my unit tests.
## how to use it?
From v0.4.0 `express-device` only works with [express](http://expressjs.com/) >= v4.x.x and [node](https://nodejs.org) >= v0.10. To install it you only need to do:
$ npm install express-device
Case you're using [express](http://expressjs.com/) 3.x.x you should install version 0.3.13:
$ npm install [email protected]
Case you're using [express](http://expressjs.com/) 2.x.x you should install version 0.1.2:
$ npm install [email protected]
`express-device` is built on top of [express](http://expressjs.com/) framework. Here's an example on how to configure express to use it:
```javascript
var device = require('express-device');
app.set('view engine', 'ejs');
app.set('view options', { layout: false });
app.set('views', __dirname + '/views');
app.use(bodyParser());
app.use(device.capture());
```
By doing this you're enabling the **request** object to have a property called **device**, which have the following properties:
<table>
<tr><td><strong>Name</strong></td><td><strong>Field Type</strong></td><td><strong>Description</strong></td><td><strong>Possible Values</strong></td></tr>
<tr>
<td>type</td>
<td>string</td>
<td>It gets the device type for the current request</td>
<td>desktop, tv, tablet, phone, bot or car</td>
</tr>
<tr>
<td>name</td>
<td>string</td>
<td>It gets the deviceExcerpt of 13,050 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
Not classified yet. Classification runs as part of npm run ingest.