Mozilla — Finally — Adds Web Serial Support to Firefox, Starting in Firefox 151
Web apps can now request access to serial ports — including USB devices — in Firefox, just like in Chromium-based browsers.
Firefox has announced official support for the Web Serial application programming interface (API), allowing web apps to connect to USB and other serial devices from within the browser — meaning web-based IDEs can flash programs onto microcontrollers with no software installation required.
"Firefox can now connect directly to microcontrollers, development boards, 3D printers, power meters, and other serial-connected hardware from the web," Mozilla's Haik Aftandilian and Greg Stoll explain in a joint announcement. "Starting in Firefox 151 for Desktop, support for the Web Serial API allows web applications to communicate with compatible devices without requiring native software. Web Serial compatible devices are popular among hobbyists, hardware hackers, educators, makers, and developers with use cases ranging from home automation to hardware prototyping and 3D printing. Web Serial support makes Firefox more useful for these kinds of projects."
Mozilla has previously declined to add Web Serial, and the related Web Bluetooth API, over concerns that it could be abused by malicious websites for everything from user fingerprinting to bricking connected devices. Years of support in browsers based on the open-source Chromium project, including Google's Chrome, have failed to deliver any such attacks — and now Firefox is, belatedly, joining the compatibility club.
"One of the organizations that has demonstrated the value of Web Serial is Adafruit, a leader in open-source hardware and STEM [Science, Technology, Engineering, and Maths] education," Aftandilian and Stoll say. "They've made it quick and easy to install CircuitPython on their devices by delivering firmware over Web Serial. Then it's straightforward to run Python programs on the device. Name your file code.py and, for most devices, the code can be installed by dragging-and-dropping the file onto the USB device. Your Python programs can interoperate with a web page over Web Serial using simple text-based I/O."
In a nod to its previous security concerns, Mozilla has implemented per-site and per-port controls: sites requesting Web Serial access will trigger a prompt that identifies the domain name requesting access and allows the user to select from a list of detected serial ports — with access to one port leaving the others still blocked. "While Web Serial still resides in the Web Incubator Community Group (WICG)," Mozilla's Aftandilian and Stoll note, "we're optimistic there's a path to standardization given its scope and long-running incubation. We are pursuing standardizing the Web Serial API in the WHATWG in a new Workstream proposal and are excited to work with ecosystem partners and standards bodies to help shape access to peripherals on the web."
Web Serial is available in the desktop version of Firefox 151 and later; Adafruit has published a "Page Playground" demonstration of what the support can offer for electronics makers.