Get Started
API Reference


expo-barcode-scanner provides a React component that renders a viewfinder for the device's camera (either front or back) and will scan bar codes that show up in the frame.

Platform Compatibility

Android DeviceAndroid EmulatoriOS DeviceiOS SimulatorWeb
Note: Only one active BarCodeScanner preview is supported currently. When using navigation, the best practice is to unmount any previously rendered BarCodeScanner component so the following screens can use <BarCodeScanner /> without issues.


→ expo install expo-barcode-scanner

If you're installing this in a bare React Native app, you should also follow these additional installation instructions.

In managed apps, scanning barcodes with the camera requires the Permission.CAMERA permission. See the usage example below.

Bar code formatiOSAndroid
interleaved2of5Yesuse itf14
Important notes:
  • When an ITF-14 barcode is recognized, it's type can sometimes be set to interleaved2of5.
  • Scanning for either PDF417 and/or Code39 formats can result in a noticeable increase in battery consumption on iOS. It is recommended to provide only the bar code formats you expect to scan to the barCodeTypes prop.

You must request permission to access the user's camera before attempting to get it. To do this, you will want to use the Permissions API. You can see this in practice in the following example.
import React, { useState, useEffect } from 'react';
import { Text, View, StyleSheet, Button } from 'react-native';
import { BarCodeScanner } from 'expo-barcode-scanner';

export default function App() {
  const [hasPermission, setHasPermission] = useState(null);
  const [scanned, setScanned] = useState(false);

  useEffect(() => {
    (async () => {
      const { status } = await BarCodeScanner.requestPermissionsAsync();
      setHasPermission(status === 'granted');
  }, []);

  const handleBarCodeScanned = ({ type, data }) => {
    alert(`Bar code with type ${type} and data ${data} has been scanned!`);

  if (hasPermission === null) {
    return <Text>Requesting for camera permission</Text>;
  if (hasPermission === false) {
    return <Text>No access to camera</Text>;

  return (
    <View style={styles.container}>
        onBarCodeScanned={scanned ? undefined : handleBarCodeScanned}
      {scanned && <Button title={'Tap to Scan Again'} onPress={() => setScanned(false)} />}

%%placeholder-start%%const styles = StyleSheet.create({ ... }); %%placeholder-end%%const styles = StyleSheet.create({
  container: {
    flex: 1,
    flexDirection: 'column',
    justifyContent: 'center',

import { BarCodeScanner } from 'expo-barcode-scanner';
Note: Passing undefined to the onBarCodeScanned prop will result in no scanning. This can be used to effectively "pause" the scanner so that it doesn't continually scan even after data has been retrieved.

  • type (string) -- Camera facing. Use one of BarCodeScanner.Constants.Type. Use either Type.front or Type.back. Same as Camera.Constants.Type. Default: Type.back.
  • barCodeTypes (Array\<string>) -- An array of bar code types. Usage: BarCodeScanner.Constants.BarCodeType.<codeType> where codeType is one of these listed above. Defaults to all supported bar code types. It is recommended to provide only the bar code formats you expect to scan to minimize battery usage. For example: barCodeTypes={[BarCodeScanner.Constants.BarCodeType.qr]}.
  • onBarCodeScanned (function) -- A callback that is invoked when a bar code has been successfully scanned. The callback is provided with an BarCodeScanner.BarCodeScannerResult.

Asks the user to grant permissions for accessing the camera.
On iOS this will require apps to specify the NSCameraUsageDescription entry in the Info.plist

A promise that resolves to an object of type PermissionResponse.

Checks user's permissions for accessing the camera.

A promise that resolves to an object of type PermissionResponse.

Scan bar codes from the image given by the URL.

  • url (string) -- URL to get the image from.
  • barCodeTypes (Array\<BarCodeScanner.Constants.BarCodeType>) -- (as in prop) An array of bar code types. Default: all supported bar code types.
    Note: Only QR codes are supported on iOS.

A possibly empty array of objects of the shape { type: BarCodeScanner.Constants.BarCodeType, data: string }, where the type refers to the bar code type that was scanned and the data is the information encoded in the bar code.

Object of type BarCodePoint contains following keys:
  • x (number) -- The x value.
  • y (number) -- The y value.
Those coordinates are represented in the coordinate space of the barcode source (e.g. when you are using the barcode scanner view, these values are adjusted to the dimensions of the view).

Object of type BarCodeSize contains following keys:
  • height (number) -- The height value.
  • width (number) -- The width value.

Object of type BarCodeBounds contains following keys:

Object of type BarCodeScannerResult contains following keys:
  • type (BarCodeScanner.Constants.BarCodeType) -- The barcode type.
  • data (string) -- The information encoded in the bar code.
  • bounds : BarCodeScanner.BarCodeBounds -- (Optional) The BarCodeBounds object.
  • cornerPoints : Array<BarCodeScanner.BarCodePoint> -- (Optional) Corner points of the bounding box.
NOTE bounds and cornerPoints are not always available. On iOS, for code39 and pdf417 you don't get those values. Moreover, on iOS, those values don't have to bounds the whole barcode. For some types, they will represent the area used by the scanner.