1. React Native
  2. Props

React Native

Props

WARNING

v3.0.0 Breaking Change: The VisionSdkView component has been removed. Use VisionCamera instead. See the Release Notes for migration details.

VisionCamera Component Props

The VisionCamera component is the primary camera component for barcode scanning and OCR. It provides a streamlined API without requiring API keys or cloud configuration for basic scanning functionality.

Prop Type Default Description
ref React.Ref<VisionCameraRefProps> Imperative ref to call methods (capture, start/stop, etc.) on the camera.
scanMode 'photo' | 'barcode' | 'qrcode' | 'barcodeorqrcode' | 'ocr' | 'barcodesinglecapture' 'photo' Detection mode for the camera. Exported as the VisionCameraScanMode type - the members are all lowercase.
autoCapture boolean false Automatically capture when detection is successful
enableFlash boolean false Deprecated since v3.12.0 - use torch instead. Same native path; if both are set, torch wins and a one-time development warning fires.
zoomLevel number 1.0 Deprecated since v3.12.0 - use zoomRatio instead. Same native path; if both are set, zoomRatio wins and a one-time development warning fires.
zoomRatio number 1.0 Since v3.12.0: Canonical zoom control. Wide-normalized absolute ratio (0.5 = ultra-wide, 1.0 = wide at 1x, 3.0 = telephoto), identical on both platforms. See Camera Controls
torch boolean false Since v3.12.0: Canonical torch control. See Camera Controls
focusMode 'continuous' | 'single' | 'locked' 'continuous' Since v3.12.0: Focus mode - AF-C, AF-S, or focus fixed at its current position. See Camera Controls
pinnedLensId string undefined Since v3.12.0: Pin a specific physical lens by id (from VisionCore.getCameraCapabilities()). undefined = Auto. An unknown or unpinnable id never throws - it falls back to Auto and reports warningCode: 'lens-unavailable'. See Camera Controls
cameraFacing 'back' | 'front' 'back' Camera facing direction - 'back' for rear camera or 'front' for front-facing camera. Functional on both platforms. iOS performs a live in-place input swap; Android rebuilds the camera session, and a genuine facing switch drops pinnedLensId back to Auto. See Camera Switching
scanArea { x: number, y: number, width: number, height: number } undefined Restrict scanning to a specific region (coordinates in dp)
detectionConfig object See below Configure object detection settings
frameSkip number 10 Process every Nth frame for performance optimization. Defaults to processing 1 frame out of every 10 - lower it to detect more often, raise it for better performance.
template TemplateData | null null NEW in v3.0.0: Template for barcode pattern matching. Pass a TemplateData object to apply, or null to remove. See Template Management
onBarcodeDetected (event: { codes: Array<BarcodeResult> }) => void () => {} Fired when barcode(s) are detected
onCapture (event: { image: string, nativeImage?: string, sharpnessScore?: number, barcodes?: Array<BarcodeResult> }) => void () => {} Fired when image is captured. Only image is guaranteed - nativeImage, sharpnessScore and barcodes are optional and may be absent depending on platform and scan mode.
onRecognitionUpdate (event: { text: boolean, barcode: boolean, qrcode: boolean, document: boolean }) => void () => {} Continuous updates of detected objects
onSharpnessScoreUpdate (event: { sharpnessScore: number }) => void () => {} Image sharpness score updates (0-1)
onBoundingBoxesUpdate (event: { barcodeBoundingBoxes: Array<DetectedCodeBoundingBox>, qrCodeBoundingBoxes: Array<DetectedCodeBoundingBox>, documentBoundingBox: BoundingBox }) => void () => {} Bounding boxes for detected objects
onCameraStateChanged (event: VisionCameraStateEvent) => void () => {} Since v3.12.0: Camera state stream - status, facing, active lens, live zoom range, torch, focus mode, preview liveness, and non-fatal warnings. Replays once on attach, then throttled to about 10 Hz by the RN bindings. See Camera Controls
onError (event: { message: string, code?: number }) => void () => {} Error events

Detection Config Object

        detectionConfig={{
  text: true,              // Enable text detection (iOS only)
  barcode: true,           // Enable barcode detection
  document: true,          // Enable document detection (iOS only)
  sharpness: false,        // Enable live image sharpness scoring (default false, opt-in since it costs extra CPU/Neural Engine work)
  barcodeConfidence: 0.5,  // Barcode detection confidence (0-1, iOS only)
  documentConfidence: 0.5, // Document confidence (0-1, iOS only)
  documentCaptureDelay: 2.0 // Delay before auto-capture (seconds, iOS only)
}}

      
NOTE

Since v3.9.0: these flags now fully stop the underlying native detection work when disabled, instead of just hiding the results. Leaving text, document, or sharpness off when you don't need them reduces unnecessary camera-frame processing and device heat.

VisionCameraRefProps — Imperative Methods Reference

Method Parameters Return Description Example
capture() - void Capture image manually (when autoCapture is false) cameraRef.current?.capture()
start() - void Start camera (only needed if you previously stopped it) cameraRef.current?.start()
stop() - void Stop camera (e.g., when screen goes to background) cameraRef.current?.stop()
pauseDetection() - void Stop all detection work while keeping the camera preview and session running. Since v3.9.0 cameraRef.current?.pauseDetection()
resumeDetection() - void Resume detection previously stopped by pauseDetection(). Since v3.9.0 cameraRef.current?.resumeDetection()
rescan() - void Tear the camera session down and rebuild it. Required on Android before a repeated capture(). cameraRef.current?.rescan()
setZoom(level) level: number void Set the wide-normalized zoom ratio. Fire-and-forget - read the result back from onCameraStateChanged. cameraRef.current?.setZoom(2.0)
setTorch(enabled) enabled: boolean void Turn the torch on or off. Since v3.12.0 cameraRef.current?.setTorch(true)
setFocusPoint(x, y) x: number, y: number void One-shot focus and metering pass at a normalized point (0-1, top-left origin). Does not change focusMode, and is not re-applied after a session rebuild. Since v3.12.0 cameraRef.current?.setFocusPoint(0.5, 0.5)
setFocusSettings(settings) settings: FocusSettings void Configure the focus-image overlay and bounding-box styling. Unrelated to focusMode / setFocusPoint(). cameraRef.current?.setFocusSettings({ ... })
toggleFlash(enabled) enabled: boolean void Legacy alias for setTorch(enabled) - prefer setTorch() in new code. Fully functional and routes through the same canonical path. Not marked @deprecated in the SDK types, so there is no IDE strikethrough or compiler hint. cameraRef.current?.toggleFlash(true)
NOTE

Camera Auto-Start: The camera starts automatically when mounted - you don't need to call start() manually in most cases.

Property Control: Camera facing is controlled via the cameraFacing prop, not a ref method. Zoom, torch, focus mode and lens pinning are available both declaratively (zoomRatio, torch, focusMode, pinnedLensId) and imperatively (setZoom(), setTorch(), setFocusPoint()) - use the props for values that live in component state, and the ref methods for gesture-driven controls. See Camera Controls.

Pausing and Resuming Detection

pauseDetection() and resumeDetection() let you temporarily stop all detection work (barcode, text, document, and sharpness) without tearing the camera down:

        // Stop detection, e.g. right after a successful capture while showing a loading state
cameraRef.current?.pauseDetection();

// Resume detection later, e.g. once the loading state is dismissed
cameraRef.current?.resumeDetection();

      

This is different from calling stop(). pauseDetection() keeps the live preview visible and the camera session active, so resuming is instant, with no camera restart flicker and no permission or session setup work needed again. Use it for short-lived UI states (a loading spinner, a result screen) where you don't want the camera analyzing frames in the background, but don't want to stop the camera entirely either.

While paused:

  • None of the detection event callbacks fire (onRecognitionUpdate, onBarcodeDetected, onBoundingBoxesUpdate, onSharpnessScoreUpdate).
  • Any bounding boxes or detection indicators currently on screen are cleared immediately.
  • Any in-progress price tag detection is cancelled rather than left to finish in the background.

Switching scanMode automatically resumes detection even if it was previously paused, since changing modes rebuilds the underlying native scanner. If your UI has its own pause toggle, resync it to "on" when the user changes scan mode, the same way the example app does.


VisionCore Methods

For camera-independent OCR prediction and logging operations, use the VisionCore module instead of the component ref methods:

  • Model Management: Use VisionCore.downloadModel(), VisionCore.loadOCRModel(), etc. — See Documentation
  • Headless OCR Prediction: Use VisionCore.predictWithModule(), VisionCore.predictShippingLabelCloud(), etc. — See Documentation
  • Data Logging: Use VisionCore.logItemLabelDataToPx(), VisionCore.logShippingLabelDataToPx()See Documentation
  • Camera Capabilities: Use VisionCore.getCameraCapabilities() to snapshot the device's lenses, zoom stops, and torch/focus support without mounting a camera - See Documentation
        import { VisionCore } from 'react-native-vision-sdk';

// Model management (on-device OCR)
const module = { type: 'shipping_label', size: 'large' };
await VisionCore.downloadModel(module, apiKey, token, progressCallback);
await VisionCore.loadOCRModel(module, apiKey, token);

// Camera-independent prediction
const result = await VisionCore.predictWithModule(module, imageUri, barcodes);

// Or cloud prediction (no model required)
const cloudResult = await VisionCore.predictShippingLabelCloud(imageUri, [], options);

// Data logging
await VisionCore.logItemLabelDataToPx(imageUri, barcodes, responseData, token, apiKey, true, metadata);