express-browser-detect/README.md

33 lines
725 B
Markdown
Raw Permalink Normal View History

2023-03-28 02:03:48 +02:00
<h1 align='center'>express-browser-detect</h1>
2023-03-18 12:37:06 +01:00
This middleware helps you to easily detect the user's browser.
It uses [which-browser](https://www.npmjs.com/package/which-browser) under the hood, and all the documentation is there
# Installation
```
2023-03-28 02:03:48 +02:00
yarn add --save express-browser-detect
2023-03-18 12:37:06 +01:00
```
Or if you prefer `npm`
```
2023-03-28 02:03:48 +02:00
npm install --save express-browser-detect
2023-03-18 12:37:06 +01:00
```
# Example
```
const express = require('express');
const app = express();
const port = 3000;
2023-03-28 02:03:48 +02:00
const ex_browser = require('express-browser-detect');
2023-03-18 12:37:06 +01:00
app.use(ex_browser);
app.get('/', (req, res) => {
res.send('Your browser is: ' + req.browser.browser.toString());
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`);
})
```