{"id":17968674,"url":"https://github.com/kshyju/browserdetector","last_synced_at":"2025-08-28T04:47:33.167Z","repository":{"id":60773164,"uuid":"205005347","full_name":"kshyju/BrowserDetector","owner":"kshyju","description":"Fast \u0026 light weight browser detection \u0026 device detection for asp.net core and azure functions","archived":false,"fork":false,"pushed_at":"2024-01-02T02:07:35.000Z","size":166,"stargazers_count":43,"open_issues_count":7,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-04T01:03:19.737Z","etag":null,"topics":["azure-functions-browser-detection","browser-detection","browser-detection-in-aspnetcore","browser-detector","browserdetection","detect-browser","device-detection","device-type-detection","devicetypedetection","operating-system-detection"],"latest_commit_sha":null,"homepage":"","language":"C#","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/kshyju.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":"2019-08-28T19:13:35.000Z","updated_at":"2025-06-24T07:17:32.000Z","dependencies_parsed_at":"2023-12-18T04:29:32.379Z","dependency_job_id":"0f27629a-e459-4740-98e5-c717f5ef9c7f","html_url":"https://github.com/kshyju/BrowserDetector","commit_stats":{"total_commits":66,"total_committers":2,"mean_commits":33.0,"dds":"0.030303030303030276","last_synced_commit":"70773f14ca12edb1c6feef72dbfda00f8e32b076"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kshyju/BrowserDetector","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kshyju%2FBrowserDetector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kshyju%2FBrowserDetector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kshyju%2FBrowserDetector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kshyju%2FBrowserDetector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kshyju","download_url":"https://codeload.github.com/kshyju/BrowserDetector/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kshyju%2FBrowserDetector/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263427304,"owners_count":23464842,"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":["azure-functions-browser-detection","browser-detection","browser-detection-in-aspnetcore","browser-detector","browserdetection","detect-browser","device-detection","device-type-detection","devicetypedetection","operating-system-detection"],"created_at":"2024-10-29T14:41:13.910Z","updated_at":"2025-07-04T01:04:45.635Z","avatar_url":"https://github.com/kshyju.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BrowserDetector\n[![NuGet version (BrowserDetector)](https://img.shields.io/nuget/v/Shyjus.BrowserDetector.svg?style=flat-square)](https://www.nuget.org/packages/Shyjus.BrowserDetector/)\n\nBrowser detection capabilities for asp.net core Web API. \n\n### Supported frameworks\n\n - .NET6.0\n - .NET7.0\n - .NET8.0\n\nThis library does\n\n1. Browser detection\n2. Device type detection\n3. Operating System detection\n\n.NET framework 4.7 has `Browser` property on  `HttpContext.Request` which gives you information about the browser, from where there HTTP request came from. Unfortunately, ASP.NET core does not have this. This package can be used for browser \u0026 device detection in your ASP.NET core apps.\n\n\n\n\n## Browsers supported\n\n| Name    | Operating System | Device type |\n| ------------- | ------------- | ------------- |\n| Chrome  | Windows  | Desktop  |\n| Chrome  | Mac OS  | Desktop  |\n| Chrome  | iOS  | Mobile  |\n| Chrome  | iOS  | Tablet  |\n| Chrome  | Android  | Mobile  |\n| Chrome  | Android  | Tablet  |\n| Internet Explorer 11  | Windows  | Desktop  |\n| Edge  | Windows  | Desktop  |\n| Edge  | iOS  | Tablet  |\n| Edge  | iOS  | Mobile  |\n| Edge  | Android  | Mobile  |\n| EdgeChromium  | Windows  | Desktop  |\n| EdgeChromium  | OSX  | Desktop  |\n| Opera  | Windows  | Desktop  |\n| Opera  | Mac OS  | Desktop  |\n| Opera  | iOS  | Mobile  |\n| Opera  | iOS  | Tablet  |\n| Safari  | Windows  | Desktop  |\n| Safari  | Mac OS  | Desktop  |\n| Safari  | iOS  | Mobile  |\n| Safari  | iOS  | Tablet  |\n| Firefox  | Windows  | Desktop  |\n| Firefox  | Mac OS  | Desktop  |\n| Firefox  | iOS  | Mobile  |\n| Firefox  | iOS  | Tablet  |\n\nIf you do not see a specific browser/os/device type combo, please [open an issue](https://github.com/kshyju/BrowserDetector/issues/new)\n\n## How to use ?\n\n**Step 1:**\nInstall the [BrowserDetector nuget package](https://www.nuget.org/packages/Shyjus.BrowserDetector/)\n\n\n````\nInstall-Package Shyjus.BrowserDetector\n````\n\n**Step 2:** Enable the browser detection service by calling `AddBrowserDetection` method on `IServiceCollection` in your startup code.\n\n````\nservices.AddBrowserDetection();\n````\n**Step 3:** Inject `IBrowserDetector` to your controller class or view file or middleware and access the `Browser` property.\n\n#### Example usage in controller code\n\n````\npublic class HomeController : Controller\n{\n    private readonly IBrowserDetector browserDetector;\n    public HomeController(IBrowserDetector browserDetector)\n    {\n        this.browserDetector = browserDetector;\n    }\n    public IActionResult Index()\n    {\n        var browser = this.browserDetector.Browser;\n        // Use browser object as needed.\n\n        return View();\n    }\n}\n````\n\n#### Example usage in view code\n\n````\n@inject Shyjus.BrowserDetection.IBrowserDetector browserDetector\n\n\u003ch2\u003e @browserDetector.Browser.Name \u003c/h2\u003e\n\u003ch3\u003e @browserDetector.Browser.Version \u003c/h3\u003e\n\u003ch3\u003e @browserDetector.Browser.OS \u003c/h3\u003e\n\u003ch3\u003e @browserDetector.Browser.DeviceType \u003c/h3\u003e\n\n````\n\n#### Example usage in custom middleware\n\nYou can inject the `IBrowserDetector` to the `InvokeAsync` method.\n\n````\npublic class MyCustomMiddleware\n{\n    private RequestDelegate next;\n    public MyCustomMiddleware(RequestDelegate next)\n    {\n        this.next = next;\n    }\n    public async Task InvokeAsync(HttpContext httpContext, IBrowserDetector browserDetector)\n    {\n        var browser = browserDetector.Browser;\n\n        if (browser.Type == BrowserType.Edge)\n        {\n            await httpContext.Response.WriteAsync(\"Have you tried the new chromuim based edge ?\");\n        }\n        else\n        {\n            await this.next.Invoke(httpContext);\n        }\n    }\n}\n````\n\n### Interpreting the Name values returned by `IBrowser.Name`\n\n * Firefox - Firefox browser.\n * EdgeChromium - The new Chromium based Microsoft Edge browser.\n * Edge - The legacy Edge browser.\n * Safari - The Safari browser.\n * Chrome - The Chrome browser.\n\n### What is the Perf impact on adding this package ?\n\nI ran benchmarks on Safari and Chrome desktop user agents and those seems to return the results around **~ 1 micro second.** Heap allocation varies based on the input.\n\n```\n|         Method |     Mean |\n|--------------- |---------:|\n| Chrome_Windows | 1.057 us |\n| Safari_Windows | 1.093 us |\n````\n\n\u003e 1 micro second is one millionth of a second.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkshyju%2Fbrowserdetector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkshyju%2Fbrowserdetector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkshyju%2Fbrowserdetector/lists"}