Skip to content
Tauri
Releases

Barcode Scanner

Allows your mobile application to use the camera to scan QR codes, EAN-13 and other kinds of barcodes.

  • Android
  • iOS

This plugin requires a Rust version of at least 1.64

Install the barcode-scanner plugin to get started.

Use your project’s package manager to add the dependency:

npm run tauri add barcode-scanner

The barcode scanner plugin is available in JavaScript.

import { scan, Format } from '@tauri-apps/plugin-barcode-scanner';
// `windowed: true` actually sets the webview to transparent
// instead of opening a separate view for the camera
// make sure your user interface is ready to show what is underneath with a transparent element
scan({ windowed: true, formats: [Format.QRCode] });

By default all plugin commands are blocked and cannot be accessed. You must define a list of permissions in your capabilities configuration.

See Access Control List for more information.

src-tauri/capabilities/mobile.json
{
"$schema": "../gen/schemas/mobile-schema.json",
"identifier": "mobile-capability",
"windows": ["main"],
"platforms": ["iOS", "android"],
"permissions": ["barcode-scanner:allow-scan", "barcode-scanner:allow-cancel"]
}
PermissionDescription
barcode-scanner:allow-cancelEnables the cancel command without any pre-configured scope.
barcode-scanner:deny-cancelDenies the cancel command without any pre-configured scope.
barcode-scanner:allow-check-permissionsEnables the check_permissions command without any pre-configured scope.
barcode-scanner:deny-check-permissionsDenies the check_permissions command without any pre-configured scope.
barcode-scanner:allow-open-app-settingsEnables the open_app_settings command without any pre-configured scope.
barcode-scanner:deny-open-app-settingsDenies the open_app_settings command without any pre-configured scope.
barcode-scanner:allow-request-permissionsEnables the request_permissions command without any pre-configured scope.
barcode-scanner:deny-request-permissionsDenies the request_permissions command without any pre-configured scope.
barcode-scanner:allow-scanEnables the scan command without any pre-configured scope.
barcode-scanner:deny-scanDenies the scan command without any pre-configured scope.
barcode-scanner:allow-vibrateEnables the vibrate command without any pre-configured scope.
barcode-scanner:deny-vibrateDenies the vibrate command without any pre-configured scope.

© 2024 Tauri Contributors. CC-BY / MIT