@nordicid/nurapi-web
v0.9.9
Published
NUR RFID Reader API — browser transports (Web Serial, Web Bluetooth)
Maintainers
Readme
@nordicid/nurapi-web
Browser transports for the @nordicid/nurapi library — Web Serial and Web Bluetooth.
Install
npm install @nordicid/nurapi @nordicid/nurapi-webQuick Start
Import the package to register ser:// and ble:// URI schemes automatically:
import '@nordicid/nurapi-web';
import { NurApi } from '@nordicid/nurapi';
const reader = new NurApi();
// Must be called from a user gesture (click/tap handler)
await reader.connect('ser://request'); // Web Serial port picker
// await reader.connect('ble://request'); // Web Bluetooth device pickerBrowser Requirements
- Chromium-only — Chrome, Edge, Opera. Firefox and Safari do not support Web Serial or Web Bluetooth.
- User gesture required —
ser://requestandble://requestmust be called from a click/tap handler. - Secure context (HTTPS) — Web Serial and Web Bluetooth require HTTPS or
localhost.
Feature Detection
import { isWebSerialSupported, isWebBluetoothSupported } from '@nordicid/nurapi-web';
if (isWebSerialSupported()) {
await reader.connect('ser://request');
}
if (isWebBluetoothSupported()) {
await reader.connect('ble://request');
}Transport Registration
| Scheme | Browser API | Registered when |
|---|---|---|
| ser:// | navigator.serial | Web Serial API available |
| ble:// | navigator.bluetooth | Web Bluetooth API available |
Documentation
See the full API reference and guides at nordicid.github.io/nur_nurapi_typescript.
License
See LICENSE.
