Skip to main content

Scanner API

The Scanner API provides barcode and QR code scanning on POS devices. Use it to show the camera scanner, subscribe to scan events, or detect available scanner hardware (camera, external, or embedded).

  • Barcode scanning: Implement barcode scanning for product lookup or inventory management.
  • QR codes: Build QR code scanning for customer engagement or loyalty programs.
  • Custom workflows: Create scanning workflows that process data and trigger business logic.
  • Real-time feedback: Implement real-time scanning feedback with immediate processing.

The shopify global object provides barcode and QR code scanning capabilities. Access the following properties on shopify to read scan data, control the camera scanner, and detect available scanner hardware.

Anchor to hideCameraScanner
hideCameraScanner
() => void
required

Hide the camera scanner.

Anchor to scannerData
scannerData
required

Access current scan data and subscribe to new scan events. Use to receive real-time scan results.

Anchor to showCameraScanner
showCameraScanner
() => void
required

Show the camera scanner.

Anchor to sources
sources
required

Access available scanner sources on the device. Use to check which scanners are available (camera, external, or embedded).


  • Deduplicate scan events: The subscription can fire multiple times for the same code, including stale data from a previous scan when re-subscribing after a component remount. Track the last processed value and skip duplicates.
  • Manage camera lifecycle: Call hideCameraScanner() before showing results or a loading state. Call showCameraScanner() when the user is ready to scan again.
  • Clean up subscriptions: Call the unsubscribe function returned by subscribe() in your cleanup or unmount handler to prevent memory leaks.
  • Validate scanned data: Check the format of scanned data before processing. Show clear feedback for invalid codes, network errors, and unsupported formats.

  • The Scanner API is only available in action (modal) targets.
  • showCameraScanner() displays a full-screen system camera overlay. It doesn't return a value or promise, so there's no way to detect if the camera activated successfully.
  • Calling scannerData.current.subscribe() may immediately emit the value from a previous scan because unsubscribing does not clear the signal.

Was this page helpful?