#usb-device #usb #web-usb #devices #browser #serial #

webusb-web

WebUSB on the web 🕸️ — Access USB devices from the web browser

7 releases

new 0.3.0 Feb 9, 2025
0.2.0 Feb 9, 2025
0.1.4 Feb 7, 2025

#298 in WebAssembly

Download history 602/week @ 2025-02-04

602 downloads per month
Used in upc

Apache-2.0

42KB
688 lines

webusb-web — WebUSB on the web 🕸️

This crate provides WebUSB support in a JavaScript runtime environment, usually a web browser. It allows you to communicate with connected USB devices from a web browser.

The WebUSB API provides a way to expose non-standard Universal Serial Bus (USB) compatible devices services to the web, to make USB safer and easier to use.

This crate provides Rust support for using WebUSB when targeting WebAssembly.

MDN provides a WebUSB overview while detailed information is available in the WebUSB specification.

crates.io page docs.rs page Apache 2 license

Building

This crate depends on unstable features of the web_sys crate. Therefore you must add --cfg=web_sys_unstable_apis to the Rust compiler flags.

One way of doing this is to create the file .cargo/config.toml in your project with the following contents:

[build]
target = "wasm32-unknown-unknown"
rustflags = ["--cfg=web_sys_unstable_apis"]

License

webusb-web is licensed under the Apache 2.0 license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in webusb-web by you, shall be licensed as Apache 2.0, without any additional terms or conditions.

Dependencies

~10–19MB
~252K SLoC