After upgrading from Expo SDK 51 to SDK 52, you're correct — the expo-barcode-scanner module has been deprecated and is no longer maintained as a standalone package. Expo now recommends using expo-camera to implement barcode scanning functionality. However, proper integration requires a few key changes.
If you're encountering issues using expo-camera for barcode scanning, follow the steps below to troubleshoot and implement it correctly.
expo-camera in SDK 52:1. Install expo-camera:
bash
npx expo install expo-camera
2. Request Camera Permissions:
js
import{ Camera } from 'expo-camera'; const [permission, requestPermission] = Camera.useCameraPermissions(); useEffect(() => { requestPermission(); }, []);
3. Implement Barcode Scanner Using onBarCodeScanned:
jsx
<Camera style={{ flex: 1 }} onBarCodeScanned={({ type, data }) => { console.log(`Scanned ${type}: ${data}`); }} barCodeScannerSettings={{ barCodeTypes: [ Camera.Constants.BarCodeType.qr, Camera.Constants.BarCodeType.code128, ], }} />
Ensure your expo-camera version is compatible with SDK 52.
Wrap the Camera component in a properly styled View container.
If the onBarCodeScanned callback isn't firing, make sure the camera has proper focus and is visible on the screen.
At Technource, a leading mobile app development company, we recently encountered this transition challenge during a client project. Switching entirely to expo-camera—with correct permission handling and barcode settings—resolved the issue effectively.
If problems persist, check the official Expo SDK 52 changelog or community threads on GitHub for additional fixes and updates.