{"id":15634738,"url":"https://github.com/kennethanceyer/browser-detect","last_synced_at":"2025-04-05T12:03:47.234Z","repository":{"id":20879236,"uuid":"91160349","full_name":"KennethanCeyer/browser-detect","owner":"KennethanCeyer","description":":globe_with_meridians: simplify detecting your browser.","archived":false,"fork":false,"pushed_at":"2023-04-22T18:28:29.000Z","size":1976,"stargazers_count":132,"open_issues_count":34,"forks_count":17,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-14T22:13:50.955Z","etag":null,"topics":["browser","detect","javascript","navigator","nodejs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KennethanCeyer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-13T08:27:40.000Z","updated_at":"2024-06-18T13:34:26.781Z","dependencies_parsed_at":"2024-06-18T13:33:59.256Z","dependency_job_id":"e7d4846a-d785-4d5b-b260-f00c2f2996d3","html_url":"https://github.com/KennethanCeyer/browser-detect","commit_stats":{"total_commits":92,"total_committers":6,"mean_commits":"15.333333333333334","dds":"0.14130434782608692","last_synced_commit":"c1e37ef64e14a38e7ce0ae761423e0aa455182d0"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KennethanCeyer%2Fbrowser-detect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KennethanCeyer%2Fbrowser-detect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KennethanCeyer%2Fbrowser-detect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KennethanCeyer%2Fbrowser-detect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KennethanCeyer","download_url":"https://codeload.github.com/KennethanCeyer/browser-detect/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247332560,"owners_count":20921853,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser","detect","javascript","navigator","nodejs"],"created_at":"2024-10-03T10:56:09.560Z","updated_at":"2025-04-05T12:03:47.211Z","avatar_url":"https://github.com/KennethanCeyer.png","language":"TypeScript","readme":"\u003cp align=\"center\" style=\"margin-bottom: 2em;\"\u003e\u003cimg width=\"280px\" src=\"https://www.pigno.se/static/assets/images/browser-detect-logo.svg\"\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://nodei.co/npm/browser-detect/\"\u003e\u003cimg src=\"https://nodei.co/npm/browser-detect.png\" alt=\"NPM\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://badge.fury.io/js/browser-detect\"\u003e\u003cimg src=\"https://badge.fury.io/js/browser-detect.svg\" alt=\"npm version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://www.npmjs.com/package/browser-detect\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/browser-detect.svg\" alt=\"npm\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://gitter.im/KennethanCeyer/PIGNOSE?utm_source=badge\u0026amp;utm_medium=badge\u0026amp;utm_campaign=pr-badge\u0026amp;utm_content=badge\"\u003e\u003cimg src=\"https://badges.gitter.im/Join%20Chat.svg\" alt=\"Join the chat at https://gitter.im/KennethanCeyer/PIGNOSE\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/KennethanCeyer/browser-detect\"\u003e\u003cimg src=\"https://img.shields.io/github/stars/KennethanCeyer/browser-detect.svg?style=social\u0026amp;label=Stars\" alt=\"GitHub stars\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://opensource.org/licenses/MIT\"\u003e\u003cimg src=\"https://img.shields.io/badge/License-MIT-yellow.svg\" alt=\"License: MIT\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://travis-ci.org/KennethanCeyer/browser-detect\"\u003e\u003cimg src=\"https://travis-ci.org/KennethanCeyer/browser-detect.svg?branch=master\" alt=\"Build Status\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://coveralls.io/github/KennethanCeyer/browser-detect?branch=master\"\u003e\u003cimg src=\"https://coveralls.io/repos/github/KennethanCeyer/browser-detect/badge.svg?branch=master\" alt=\"Coverage Status\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://codecov.io/gh/KennethanCeyer/browser-detect\"\u003e\u003cimg src=\"https://codecov.io/gh/KennethanCeyer/browser-detect/branch/master/graph/badge.svg\" alt=\"codecov\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://www.codefactor.io/repository/github/kennethanceyer/browser-detect\"\u003e\u003cimg src=\"https://www.codefactor.io/repository/github/kennethanceyer/browser-detect/badge\" alt=\"CodeFactor\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://codeclimate.com/github/KennethanCeyer/browser-detect/maintainability\"\u003e\u003cimg src=\"https://api.codeclimate.com/v1/badges/328163587b12cf5cb3aa/maintainability\" alt=\"Maintainability\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://codeclimate.com/github/KennethanCeyer/browser-detect/test_coverage\"\u003e\u003cimg src=\"https://api.codeclimate.com/v1/badges/328163587b12cf5cb3aa/test_coverage\" alt=\"Test Coverage\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## :package: Installation\n\n#### npm\n\n```bash\n$ npm install browser-detect\n```\n\n#### yarn\n\n```bash\n$ yarn add browser-detect\n```\n\n## :page_with_curl: Example\n\n### Web\n\n```html\n\u003cscript src=\"node_modules/browser-detect/dist/browser-detect.umd.js\"\u003e\u003c/script\u003e\n```\n\n```javascript\nconst result = browserDetect();\nconsole.log(result);\n```\n\n**output**\n\n```javascript\n{\n    name: 'chrome',\n    version: '58.0.3029',\n    versionNumber: 58.03029,\n    mobile: false,\n    os: 'Windows NT 10.0'\n}\n```\n\n### Web with module\n\n```javascript\nimport browser from 'browser-detect';\n\nconst result = browser();\nconsole.log(result);\n```\n\n**output**\n\n```javascript\n{\n    name: 'chrome',\n    version: '58.0.3029',\n    versionNumber: 58.03029,\n    mobile: false,\n    os: 'Windows NT 10.0'\n}\n```\n\n### NodeJS\n\nJust simple :trollface:\n\n```javascript\nconst browser = require('browser-detect');\nconst result = browser();\n\nconsole.log(result);\n```\n\n**output**\n\n```javascript\n{\n    name: 'node',\n    version: '9.9.0',\n    versionNumber: 9.9,\n    mobile: false,\n    os: 'win32'\n}\n```\n\n### NodeJS with Express\n\n```javascript\nconst router = express.Router();\nconst browser = require('browser-detect');\n\nrouter.get('/', req =\u003e {\n    const result = browser(req.headers['user-agent']);\n    console.log(result);\n});\n\nreturn router;\n```\n\n**output**\n\n```javascript\n{\n    name: 'ie',\n    version: '9.0',\n    versionNumber: 9,\n    mobile: false,\n    os: 'Windows NT 10.0'\n}\n```\n\nOr set a middleware and send to `res.locals`.\n\n```javascript\n// browserDetectMiddleware.js\nconst browser = require('browser-detect');\n\nconst MiddleWare = () =\u003e req =\u003e {\n    res.locals.browser = browser(req.headers['user-agent']);\n    next();\n};\n\nmodule.exports = MiddleWare;\n```\n\n```javascript\n// app.js\n\nconst express = require('express');\nconst browserDetectMiddleware = require('./browserDetectMiddleware');\n\nconst app = express();\napp.use(browserDetectMiddleware())\n```\n\nView will can access `browser` variable.\n\n```ejs\n\u003c!-- view.ejs --\u003e\n\n\u003c%=JSON.stringify(browser)%\u003e\n```\n\n**output**\n\n```javascript\n\"{ name: 'firefox', version: '53.0.0', versionNumber: 53, mobile: false, os: 'Windows NT 10.0' }\"\n```\n\n## :page_with_curl: Demo\n\n#### Web\n\n- open `examples/client.html` by your browser.\n\n#### NodeJS\n\n- open command or terminal\n- move directory to `browser-detect` path that you download\n- type following code\n\n```bash\n$ node ./examples/server.js\n```\n\n## :zap: Type\n\n| name | type | description | example |\n| ---- | ---- | ----------- | ------- |\n| name | string | a browser name | ie, chrome, firefox |\n| version | string | browser or node version | 59.2.22 |\n| versionNumber | number | browser or node number casted to number | 59.222 |\n| mobile | boolean | if browser is in mobile environment, it will be true | true |\n| os | string | os type name | Windows NT 10.0 |\n\n## :triangular_flag_on_post: Roadmap\n\n- [x] detect browser both compatible client and server\n- [x] support AMD and CommonJS module feature\n- [x] support typings\n- [x] support guideline and documentations for contributors\n- [x] support browser compatity to IE7\n- [x] support to detect mobile and OS\n- [x] support CI (TravisCI)\n- [x] support unit tests\n- [ ] support e2e tests\n- [ ] suport cdn\n\n## :mag_right: Compatibility\n\n- [x] IE 7+\n- [x] Chrome (Windows, MacOS)\n- [x] Edge\n- [x] Firefox\n- [x] Safari (Windows, MacOS)\n- [x] Opera\n- [x] Android\n- [x] Chromium Browsers (Will be named chrome)\n\n## :octocat: Contribution\n\n### environment\n\n1. clone project from Github\n\n```bash\n$ git clone git@github.com:KennethanCeyer/browser-detect.git\n```\n\n2. install npm packages\n\n```bash\n$ cd browser-detect\n$ npm install\n```\n\n3. build sources\n\n```bash\n$ npm run build\n```\n\n### test\n\n```bash\n$ npm run test\n```\n\n## :yellow_heart: Contributors\n\n- [**yarkeev**](https://github.com/yarkeev)\n- [**vlewin**](https://github.com/vlewin)\n\n## :mag_right: License\n\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FKennethanCeyer%2Fbrowser-detect.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2FKennethanCeyer%2Fbrowser-detect?ref=badge_large)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkennethanceyer%2Fbrowser-detect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkennethanceyer%2Fbrowser-detect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkennethanceyer%2Fbrowser-detect/lists"}