Scanner Component API Reference

Complete API reference for the React Native Scanner component's props, types, and 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
detectionType'barcode' | 'face''barcode'What to detect. 'face' enables on-device face detection
cameraPosition'back' | 'front''back'Which camera to use. Face mode usually wants 'front'
faceDetectionFaceDetectionConfigFace overlay styling when detectionType="face"
onFacesDetected(event: FacesDetectedEvent) => voidFires every frame with detected faces (face mode only)

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

FaceDetectionConfig

Used when detectionType="face". See the full Face Detection guide.

FieldTypeDefaultDescription
enabledbooleantrueDraw face overlay graphics
boxColorstring#2BE2C2Face box border color
boxWidthnumber2Box border thickness
boxRadiusnumber12Rounded corner radius
fillColorstringOptional fill inside the box
showLandmarksbooleantrueDraw landmark dots (eyes, nose, mouth)
showContoursbooleantrueDraw face outline / contour dots
landmarkColorstring#2BE2C2Color of landmark and contour dots
landmarkRadiusnumber3Radius of each dot
performanceMode'fast' | 'accurate''fast'Speed vs. accuracy (Android ML Kit)

FacesDetectedEvent

interface FacesDetectedEvent {
  faces: FaceResult[];
  count: number;
}

interface FaceResult {
  bounds: { x: number; y: number; width: number; height: number };
  rollAngle?: number;
  yawAngle?: number;
  pitchAngle?: number;  // iOS 15+
  trackingId?: number;
}

Fires every camera frame in face mode. Coordinates are in view space (same as barcode bounds).


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
Face detectionVision landmarksML Kit face detection
pitchAngle in FaceResultiOS 15+Always available
trackingId in FaceResultNot providedWhen contours disabled
onError eventNative only (not in Scanner)Not in Scanner