Capacitor & Ionic

Capacitor Barcode Scanner SDK

Add barcode, MRZ and VIN scanning to Capacitor and Ionic apps on Android and iOS. Install the barkoder-capacitor plugin from npm, control the scanner from TypeScript, and test it on your own barcodes with a free 30-day trial.

capacitor barcode scanner

One Capacitor barcode plugin for Ionic, Angular, React and Vue apps

barkoder-capacitor is a Capacitor barcode plugin published on npm. It opens the native barKoder scanner over an element in your page and sends results back to JavaScript. The docs show an Angular example, and official GitHub examples cover Vue and React.

Install the Capacitor barcode scanner

Add the plugin and sync your native projects:

Shell
          npm install barkoder-capacitor
          npx cap sync
        

The plugin builds for Android and iOS and requires @capacitor/core 6.0.0 or later. Without a license it still scans, but results come back marked (Unlicensed) and only partly readable, so request a trial key before you measure anything.

Start your free trial

Building with Ionic or Cordova?

Ionic on Capacitor: install barkoder-capacitor as shown. It is the same ionic barcode scanner for Ionic Angular, React and Vue projects.

Ionic on Cordova: use the barkoder-cordova plugin. Ionic Angular projects can call it through the @awesome-cordova-plugins/barkoder wrapper.

Plain Cordova: the cordova barcode scanner plugin installs with one command:

Shell
                cordova plugin add barkoder-cordova
              
Go to the Cordova Barcode Scanner Plugin

Scan your first barcode from TypeScript

This Angular example is copied from the barkoder-capacitor README and the Capacitor general example. React and Vue apps call the same Barkoder methods.

  1. Listen Add a listener for barkoderResultEvent and read decoderResults from each BarkoderResult.
  2. Register Call registerWithLicenseKey with your trial or production key.
  3. Place Pass the size and position of your barkoderView element to initialize.
  4. Scan Enable the barcode types you need, set the region of interest and call startScanning.
your-page.ts
              import { Barkoder, BarkoderResult, BarcodeType } from 'barkoder-capacitor'
              @ViewChild('barkoderView') barkoderViewRef!: ElementRef;
              constructor() {
              Barkoder.addListener('barkoderResultEvent', (data: any) => {
              console.log('barkoderResultEvent was fired');
              const barkoderResult = new BarkoderResult(data);
              if (barkoderResult) {
              barkoderResult.decoderResults.forEach((result, index) => {
              console.log(`Result ${index + 1}: ${result.textualData}`);
              });
              }
              });
              }
              ngAfterViewInit() {
              Barkoder.registerWithLicenseKey({ licenseKey: "YOUR_LICENSE_KEY" });
              setTimeout(() => {
              const boundingRect = this.barkoderViewRef.nativeElement.getBoundingClientRect() as DOMRect;
              Barkoder.initialize({
              width: Math.round(boundingRect.width),
              height: Math.round(boundingRect.height),
              x: Math.round(boundingRect.x),
              y: Math.round(boundingRect.y),
              });
              this.setBarkoderSettings();
              this.setActiveBarcodeTypes();
              }, 200);
              }
              setActiveBarcodeTypes() {
              Barkoder.setBarcodeTypeEnabled({ type: BarcodeType.qr, enabled: true });
              Barkoder.setBarcodeTypeEnabled({ type: BarcodeType.code128, enabled: true });
              Barkoder.setBarcodeTypeEnabled({ type: BarcodeType.ean13, enabled: true });
              }
              setBarkoderSettings() {
              Barkoder.setRegionOfInterestVisible({value: true});
              Barkoder.setRegionOfInterest({ left: 5, top: 5, width: 90, height: 90 });
              Barkoder.setImageResultEnabled({ enabled: true});
              Barkoder.setBarcodeThumbnailOnResultEnabled({ enabled: true});
              }
              startScanning() {
              Barkoder.startScanning();
              }
            
your-page.html
              <div id="barkoderView" #barkoderView >
            
your-page.scss
              #barkoderView {
              height: 400px;
              }
            

Prefer a complete project? See the Vue starter example and the React full demo app on GitHub.

Continuous scanning, MultiScan, MRZ, VIN and DPM in Capacitor

Each mode is a few calls on the same Barkoder object. The snippets come from the Capacitor examples in the barKoder docs.

Continuous scanning

Keep the camera session open

Scan item after item without restarting the scanner. The duplicate threshold decides what happens with repeats: -1 reads each barcode once, 0 reads it again with no delay, and a value above 0 waits that many seconds. Use this setup when you need a Capacitor continuous scanning SDK for receiving, counting or picking.

TypeScript
                  Barkoder.setCloseSessionOnResultEnabled({enabled: false});
                  Barkoder.setThresholdBetweenDuplicatesScans({value: 0}); // it can take values -1, or n > 0
                
Enable continuous scanning in Capacitor →

Batch MultiScan

Many barcodes in one pass

Batch MultiScan reads several barcodes of any type at once, which makes the plugin a Capacitor multiscan SDK for shelves, cartons and pallets. The example allows up to 200 results, caches codes for 3 seconds and sets decoding speed and resolution to normal, as the docs recommend.

TypeScript
                  Barkoder.setCloseSessionOnResultEnabled({enabled: false});
                  Barkoder.setMaximumResultsCount({value: 200});
                  Barkoder.setMulticodeCachingDuration({value: 3000});
                  Barkoder.setMulticodeCachingEnabled({enabled :true});
                  // For best result decoding speed should be normal, and barkoder resolution should be normal
                  Barkoder.setDecodingSpeed({value: DecodingSpeed.normal});
                  Barkoder.setBarkoderResolution({value: BarkoderResolution.normal});
                
Enable Batch MultiScan in Capacitor →

MRZ scanning

Passports, ID cards and visas

One line turns the plugin into a Capacitor MRZ scanner plugin. It reads the machine-readable zone of travel and identity documents and returns data such as name, nationality, passport number and expiration date.

TypeScript
                  Barkoder.setBarcodeTypeEnabled({ type: BarcodeType.idDocument, enabled: true });
                
Enable MRZ mode in Capacitor →

VIN scanning

Code 39, Code 128, Data Matrix and QR

A VIN can be printed in four barcode types. The Capacitor VIN scanning SDK setup enables them with VIN restrictions, slow decoding and high resolution. A separate example adds OCR VIN support, which reads the printed characters when the barcode can't be decoded.

TypeScript
                  Barkoder.setEnableVINRestrictions({value: true});
                
Enable VIN mode in Capacitor →

DPM mode

Codes etched or printed on parts

Direct Part Marking puts a Data Matrix code straight onto metal or plastic, without a label. As a Capacitor DPM barcode scanner, the plugin enables Data Matrix with DPM mode, slow decoding, FHD resolution and a small region of interest.

TypeScript
                  Barkoder.setBarcodeTypeEnabled({ type: BarcodeType.datamatrix, enabled: true });
                  Barkoder.setDatamatrixDpmModeEnabled({ enabled: true });
                  Barkoder.setDecodingSpeed({ value: DecodingSpeed.slow });
                  Barkoder.setBarkoderResolution({ value: BarkoderResolution.FHD });
                  Barkoder.setRegionOfInterest({ left: 40, top: 40, width: 20, height: 10 });
                  Barkoder.setRegionOfInterestVisible({ value: true });
                
Enable DPM mode in Capacitor →

Damaged and difficult barcodes

The same decoding engine as the native SDKs

  • MatrixSight® reads QR and Data Matrix codes with missing finder, timing or alignment patterns.
  • Segment Decoding® reads crumpled, wrinkled or curved 1D barcodes.
  • DeBlur reads EAN and UPC codes with motion, lens or focus blur.
  • PDF417-LineSight® reads PDF417 barcodes with missing start or stop patterns and data columns.
  • AR Mode draws boxes and barcode status on the camera preview.
  • Gallery scan decodes BMP, PNG and JPG images with scanImage.
Enable the South African driving license parser in Capacitor →

Where the Capacitor plugin runs

barkoder-capacitor wraps the native Android and iOS SDKs, so your web code gets the same decoding as a native app.

Targets and requirements

  • Android and iOS builds of Capacitor 6 or later.
  • Node.js and npm, Xcode on macOS for iOS, and Android Studio for Android.
  • Minimum OS: Android 5.0 (API 21) and iOS 15.
  • Camera: at least 1280×720. Devices with an 8 MP autofocus camera are recommended.
  • Scanning runs on the device. The SDK goes online only for the license check, and each device must reach the licensing server at least once every 30 days.

Barcode types

1D barcodes

Codabar, Code 11, Code 25, Code 32, Code 39, Code 93, Code 128, GS1 DataBar, GS1 Composite, EAN-8, EAN-13, Interleaved 2 of 5, ITF-14, MSI Plessey, Postal Barcodes, Telepen, UPC-A, UPC-E and more.

2D barcodes

Aztec Code, Aztec Compact, Data Matrix, DotCode, MaxiCode, PDF417, Micro PDF417, QR Code and Micro QR Code.

See all supported barcode types →

Scanning in a browser or PWA instead? The Capacitor plugin targets native builds. For the browser, use the Web Barcode Scanner SDK (WASM). For other cross-platform stacks, see the cross-platform barcode SDK overview.

barKoder, ML Kit plugins or older community plugins?

Free plugins such as @capacitor/barcode-scanner and @capacitor-mlkit/barcode-scanning cover many apps. Here is how to decide when to use a commercial SDK instead.

A free plugin is often enough when

  • You scan clean QR codes and retail barcodes in good light.
  • One result per scan is all your workflow needs.
  • You also want a browser fallback through the Barcode Detection API.
  • No vendor support or license budget is available.

barKoder fits better when

  • Labels are damaged, wrinkled, blurred or engraved, or you need DotCode, MaxiCode or postal barcodes.
  • You need MRZ, VIN or PDF417 ID scanning with parsing on the device.
  • You need continuous scanning or Batch MultiScan with duplicate control and AR overlays.
  • You want one engine across Capacitor, Cordova, native and web apps, and free developer support during integration.

Still on @capacitor-community/barcode-scanner (last release in May 2023) or phonegap-plugin-barcodescanner (deprecated on npm)? Plan the move while you are testing, and compare on the same samples and devices.

One scanning engine for Capacitor, Cordova, native and web

The engine behind barkoder-capacitor also ships as native, web, desktop and cross-platform SDKs, so the same decoding runs in every app you build.

  • 7 native & desktop SDKs
  • 6 cross-platform integrations
  • One consistent scanning core

Cross-platform scanning in production

Teams that needed the same scanning results on every device they support.

Lotos Tourist by Datalab Montenegro

Montenegro · Tourism guest registration

Less than a dayto fully implement the SDK

Chose barKoder for MRZ scanning in the Lotos Tourist app after testing both open-source and commercial alternatives, for consistent results on Android and iOS, including older devices.

Read the story →

WayMark Infotech

South Africa · Voter registration

Up to 80%faster registration processing

Reads PDF417 and MRZ data on an Android app and a React web portal, with offline scanning in remote areas and 500 licenses deployed.

barKoder's PDF417 scanning accuracy and cross-platform reliability exceeded our expectations.Paul Sentle, WayMark Infotech
Read the story →

inexto

Switzerland · Track and trace

Migrated from Cognexfor DPM scanning on industrial mobile computers

Uses barKoder in two factory and logistics track-and-trace projects and lists wide platform support among its reasons.

What truly made us choose barKoder was the simplicity of integration and high performance in DPM barcode scanningNicolas Schaefer, Head of R&D, inexto
Read the story →

Try barKoder on your phone or in your browser

Install the free barKoder demo app, or open the web demo, and scan your own barcodes before you integrate the SDK.

iPhone and iPad

barKoder demo app for iOS

Scan with your camera, or point it at the QR code to open the App Store.

Download on the App Store
QR code linking to the barKoder demo app on the App Store

Android phones and tablets

barKoder demo app for Android

Scan with your camera, or point it at the QR code to open Google Play.

Get it on Google Play
QR code linking to the barKoder demo app on Google Play

Any modern browser

barKoder web demo

Runs the Web SDK in your browser, on desktop or mobile, with nothing to install.

Open the web demo
QR code linking to the barKoder web demo

Test with known samples. Print or display the testing sheet and scan each 1D and 2D barcode with the demo app. The data sheet summarizes the SDK for your team.

Capacitor, Ionic and Cordova barcode scanner questions

Does barKoder work as an Ionic barcode scanner?

Yes. Ionic apps that run on Capacitor install barkoder-capacitor like any other Capacitor plugin, whether the UI is Angular, React or Vue. Ionic apps that still run on Cordova use barkoder-cordova, and Ionic Angular projects can call it through the @awesome-cordova-plugins/barkoder wrapper.

I use Cordova. Which plugin do I need?

Install barkoder-cordova with cordova plugin add barkoder-cordova. The Cordova Barcode Scanner Plugin page and the Cordova installation guide cover setup, with Angular, React, Vue and vanilla JavaScript examples.

Which Capacitor versions are supported?

barkoder-capacitor requires @capacitor/core 6.0.0 or later. Check the barkoder-capacitor package on npm for the current release.

Does the Capacitor plugin scan in the browser?

No. The plugin targets Android and iOS builds. To scan in a browser or a PWA, use the Web Barcode Scanner SDK (WASM), which runs on browsers that support WebAssembly.

How is barKoder different from @capacitor-mlkit/barcode-scanning?

The ML Kit plugin is free and reads common formats well in good conditions. barKoder is a commercial SDK built for damaged, blurred and engraved barcodes, MRZ and VIN scanning, Batch MultiScan, AR overlays and on-device document parsers. Test both on the same samples, then check barKoder pricing.

Can I scan passports, ID cards and South African driving licenses in a Capacitor app?

Yes. Enable the idDocument type to read the MRZ on passports, ID cards and visas. For the PDF417 barcode on South African driving licenses, the SA driving license parser example shows the Capacitor calls, including the options for South African ID cards and vehicle license discs.

Does scanning need an internet connection?

Only for the license check. The SDK checks the license key with the barKoder licensing server when the app initializes it. All scanning runs on the device, and each device must reach the licensing server at least once every 30 days to keep returning licensed results.

How does the free trial work?

Get a key on the trial page or in the barKoder portal. A trial license lasts 30 days and can be deployed to up to 25 devices, and it is meant for development and staging. Without a license the SDK still scans, but results come back marked (Unlicensed) and only partly readable.

Add barcode scanning to your Capacitor or Ionic app

Install barkoder-capacitor and test it on your own barcodes and devices with a free 30-day trial, or talk to an SDK expert about your project.