This sample demonstrates how to use the BarcodeScanner API from the Dynamsoft Barcode Reader JavaScript SDK to scan multiple barcodes continuously from a video stream in a web application.
- Scan multiple 1D/2D barcodes
- Live video decoding using
BarcodeScannercomponent - Easy integration into your web application
- UI rendered into a customizable container
The sample uses the BarcodeScanner class to launch a scanner and decode barcodes from a camera stream. The key configuration includes:
- License Key – Required to activate the SDK.
engineResourcePaths– Points to required resources hosted on a CDN or locally.- UI container – An HTML element where the scanner is rendered.
const config = {
license: "YOUR-LICENSE-KEY",
engineResourcePaths: {
// feel free to change it to your own path
rootDirectory: "https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.0.6000/dist/",
},
container: ".barcode-scanner-view",
scanMode: Dynamsoft.EnumScanMode.SM_MULTI_UNIQUE,
showResultView: true,
showUploadImageButton: true,
scannerViewConfig: {
showCloseButton: true
},
};The BarcodeScanner instance is created and launched like this:
const barcodeScanner = new Dynamsoft.BarcodeScanner(config);
barcodeScanner.launch();- This sample scans multiple unique barcodes, you can configure
scanModeto change the behavior to scan one single barcode. - To avoid network-related loading issues, consider hosting all required resources locally.
This sample simulates a shopping experience where users scan barcodes to add items to a dynamic cart.
- Scan multiple 1D/2D barcodes
- Live video decoding using
BarcodeScannercomponent - Floating and draggable scanner window.
- Dynamic cart updates on each scan.
The scanning logic mirrors the Hello World sample, but scanned results populate the cart instead of just displaying in the result view.
The UI features a "Scan Barcode" button, a styled cart, and basic interactivity with vanilla JavaScript and CSS.
A list of 20 dummy products is used, with each scan randomly adding a product to the cart showing its name, shortened barcode, and price.
This project is a simple web-based inventory management tool that uses BarcodeScanner to scan barcodes in batches and provide real-time analysis of the scanned data.
-
Automatically deduplicate barcodes in each session
-
Show session summary:
- Total unique barcodes
- Barcode type distribution
- Session duration
-
Track duration of each scan session
-
The scanner is embedded using
BarcodeScannerwithSM_MULTI_UNIQUEmode to capture unique barcodes. -
Once the scan completes, the results are analyzed.
-
You can click the back arrow to restart scanning.
-
The barcode value must be unique, otherwise it won’t be counted.
-
Applicable scenarios may include:
- Warehouse inventory checks
- Retail stock intake
- Barcode-based asset tracking
- Batch QR code scanning
Multiple samples are provided for single barcode scanning. These samples can be easily adapted to scan multiple unique barcodes by simply updating the config object.
- Hello World: Scan single barcode from video stream with minimum code in JavaScript.
- Scan and Search: Scan a barcode to retrieve the relevant product information from the database in JavaScript.
- Pick one to fill: Pick one and auto-fill fields by simply opening the camera and scanning a group of barcodes.
- Use customized template: Use different customized templates for scanning various barcode types.
- Hello World in Angular: Read single barcode from camera in an Angular application.
- Hello World in React: Read single barcode from camera in a React application.
- Hello World in Vue: Read single barcode from camera in a Vue application.
- Hello World in Svelte: Read single barcode from camera in a Svelte application.
- Hello World in Capacitor: Read single barcode from camera in a Capacitor application.
- Hello World in Webview: Read single barcode from camera in a Webview application.
- Hello World in Typescript: Read single barcode from camera in a Typescript application.
- Hello World in Electron: Read single barcode from camera in a Electron application.
- Hello World in Blazor: Read single barcode from camera in a Blazor application.
- Hello World in RequireJS: Read single barcode from camera in a RequireJS application.
- Hello World in ES6: Read single barcode from camera in a ES6 application.
- Hello World in PWA: Read single barcode from camera in a PWA application.