Scanner API Reference

Complete reference for all Scanner props, types, and the ScanResult object.

Scanner props

PropTypeDefaultDescription
styleViewStyleLayout style for the camera preview view
onCodeScanned(result: ScanResult) => voidCallback fired when a stable code is detected
autoStartbooleantrueWhether to start the camera when the component mounts
torchbooleanfalseTurn on the flashlight
enableFreezeFramebooleanfalsePause camera after scan, play animation, then resume
boundingBoxBoundingBoxConfigConfiguration for drawing boxes around detected codes
scanRegionScanRegionConfigConfiguration for restricting scanning to a defined area

Ref methods

Attach a ref to Scanner to call these methods imperatively:

const scannerRef = useRef(null);
<Scanner ref={scannerRef} ... />
MethodDescription
resumeScanning()Resume camera and detection after freeze frame or manual pause

ScanResult

interface ScanResult {
  data: string;       // The decoded string value
  type: string;       // Barcode format, e.g. "QR_CODE"
  rawBytes?: string;  // Base64 raw bytes (Android only)
  bounds?: {
    x: number;
    y: number;
    width: number;
    height: number;
  };
}

type values: QR_CODE, EAN_13, EAN_8, UPC_A, UPC_E, CODE_128, CODE_39, CODE_93, CODABAR, DATA_MATRIX, PDF417, AZTEC, ITF


ScanRegionConfig

FieldTypeDefaultDescription
enabledbooleanRequired. Must be true to activate
widthnumber300Region width in dp/points
heightnumber300Region height in dp/points
offsetXnumber0Horizontal offset from center
offsetYnumber0Vertical offset from center
cornerRadiusnumber12Corner radius of the cutout
borderColorstring#FFFFFFBorder color
borderWidthnumber3Border thickness
showBorderbooleantrueDraw the border
dimColorstring#000000Dim mask color
dimAlphanumber180Dim mask opacity (0–255)
showCornersbooleantrueShow corner bracket decorations
cornerLengthnumber30Corner bracket arm length
cornerWidthnumber4Corner bracket line width
showHintbooleantrueShow hint text below the frame
hintTextstring"Align code within frame"Hint message
hintTextColorstring#FFFFFFHint text color
hintTextSizenumber14Hint font size

BoundingBoxConfig

FieldTypeDefaultDescription
enabledbooleantrueDraw boxes around detections
borderColorstring#FFFFFFBox border color
borderWidthnumber4Border thickness
borderRadiusnumber12Rounded corner radius
fillColorstringOptional fill color (supports alpha)
showTextbooleantrueShow decoded value as a text label
textColorstring#000000Label text color
textSizenumber14Label font size
textBackgroundColorstring#FFFFFFLabel background color

Color format

All color strings follow these two formats:

  • #RRGGBB — fully opaque (e.g. #FF5733)
  • #RRGGBBAA — with transparency (e.g. #FF573380 = 50% transparent)

The alpha value is the last two characters, not the first.


Platform differences

FeatureiOSAndroid
rawBytes in ScanResultNot filledBase64 string
Default barcode formatsAll 13 typesQR code only
onError eventNative only (not in Scanner)Not in Scanner