All Projects → BlazorExtensions → WebUSB

BlazorExtensions / WebUSB

Licence: MIT license
HTML5 WebUSB APIs for Microsoft ASP.Net Core Blazor

Programming Languages

C#
18002 projects
typescript
32286 projects
HTML
75241 projects
javascript
184084 projects - #8 most used programming language

Canvas

HTML5 WebUSB API implementation for Microsoft Blazor

Build Package Version NuGet Downloads License

Blazor Extensions

Blazor Extensions are a set of packages with the goal of adding useful things to Blazor.

Blazor Extensions WebUSB

This package wraps HTML5 WebUSB APIs.

Installation

Install-Package Blazor.Extensions.WebUSB

Sample

Usage

  • First add the USB services on Blazor IServiceCollection:
public void ConfigureServices(IServiceCollection services)
{
    services.UseWebUSB(); // Makes IUSB available to the DI container
}

To consume on your .cshtml:

  • On your _ViewImports.cshtml add the using entry:
@using Blazor.Extensions.WebUSB
  • Then, on your .cshtml inject the IUSB:
@inject IUSB usb

And then use the usb object to interact with connected USB devices thru your Blazor application.

To inject on a BlazorComponent class:

Define a property of type IUSB and mark it as [Injectable]:

[Inject] private IUSB _usb { get; set; }

Then use the _usb variable to interact with the connected USB devices.

Note: For now, you have to call await IUSB.Initialize() once in your application. This is a temporary requirement and we are looking on a better way to automatically register to Connect/Disconnect events.

Contributions and feedback

Please feel free to use the component, open issues, fix bugs or provide feedback.

Contributors

The following people are the maintainers of the Blazor Extensions projects:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].