Docs
API

BarcodeScanner

NameTypeDefault ValueDescription
optionsScanOptionsDEFAULT_OPTIONS/
onCapture(barcodes: DetectedBarcode[]) => any/Triggered when the specified QR code is scanned
trackConstraintsMediaTrackConstraintsDEFAULT_CONSTRAINTSBased on the MediaTrackConstraints (opens in a new tab) standard

useCamera

NameTypeDefault ValueDescription
refRefObject<HTMLVideoElement>Required*HTMLVideoElement instance
trackConstraintsMediaTrackConstraintsDEFAULT_CONSTRAINTSBased on the MediaTrackConstraints (opens in a new tab) standard

DEFAULT_CONSTRAINTS

{
  width: { min: 640, ideal: 1280 },
  height: { min: 480, ideal: 720 },
  facingMode: {
    ideal: 'environment'
  },
  advanced: [
    { width: 1920, height: 1280 },
    { aspectRatio: 1.333 }
  ]
}

useScanning

NameTypeDefault ValueDescription
refRefObject<HTMLVideoElement>Required*HTMLVideoElement instance
optionsScanOptionsDEFAULT_OPTIONSdelay: scan interval
formats: barcode format, support formats

DEFAULT_OPTIONS

{
  delay: 1000,
  formats: ['qr_code']
}

useTorch

NameTypeDefault ValueDescription
openBooleanfalseEnabled by default

useStreamState

Manage stream obtained from useCamera

function useStreamState (): [MediaStream | undefined, (newState: MediaStream) => void]

Types

ScanOptions

interface ScanOptions {
  delay?: number
  formats?: string[]
}