How to handle user-agent in nodejs environment?

Undefined Behavior picture Undefined Behavior · Mar 9, 2014 · Viewed 51.3k times · Source

I start to using the package "ua-parser" but the creator is too busy to mantain or commit... the npm ua-parser is outdate, and need to download directly from github. Someone know about other good package like ua-parser that is updated and can be used with expressjs? Or have a way to handle just with expressjs?

Answer

tpae picture tpae · Mar 9, 2014

Have you looked at:

Or, write your own middleware:

app.use(function(req, res, next) {
  res.locals.ua = req.get('User-Agent');
  next();
});

Reference: get user agent from inside jade