React Native
Camera Switching
The Vision SDK supports switching between front and back cameras on supported devices. Camera switching is driven declaratively through the cameraFacing prop on VisionCamera.
Platform Support (as of v3.12.0)
- iOS: Fully functional - a live in-place input swap on the running session
- Android: Fully functional - the camera session is rebuilt around the new facing
Both platforms apply the cameraFacing prop for real. The remaining difference is how: iOS swaps
the input on the existing session, Android stops and restarts the camera with the new facing, so
Android shows a brief preview gap on switch. Read state.facing back from
onCameraStateChanged rather than assuming the prop took effect instantly.
Switching with cameraFacing
Set the cameraFacing prop to 'back' or 'front' and the camera moves to that facing. There is no ref method for switching cameras.
Basic Implementation
Props
Type Export
Advanced Examples
Camera Toggle Icon Overlaid on the Preview
VisionCamera accepts children, so a toggle control can be rendered directly on top of the preview:
Platform-Specific Behavior
iOS
On iOS, camera switching works seamlessly:
- Instant switching between cameras - the input is swapped in place on the running session
- Maintains current scanning mode and settings
- No frame drops during transition
- Works with all scan modes (barcode, QR, OCR, photo)
Android
On Android, camera switching is fully functional:
- The prop is applied to the underlying camera settings and takes effect
- Maintains current scanning mode and settings
- The camera session is stopped and restarted on the new facing, so expect a brief preview gap rather than an instant swap
- Works with all scan modes (barcode, QR, OCR, photo)
A facing switch resets pinnedLensId on Android. A pin is facing-specific, so a genuine facing
change drops the lens selection back to Auto. Do not drive cameraFacing and pinnedLensId
together - see Camera Controls for the full comparison.
Best Practices
Always provide a UI control for camera switching - don't make users guess:
Show current camera state to the user:
Confirm the switch instead of assuming it. Both platforms apply the prop, but Android restarts the session to do it, so the preview is briefly down. Drive your UI off the camera's reported facing rather than off local state alone - and do not gate the control by platform:
Preserve other camera settings when switching:
Troubleshooting
Camera doesn't switch
- Verify the prop/method value is actually changing
- Check device has both front and back cameras
- Ensure camera permissions are granted for both cameras
- Confirm you are on v3.12.0 or later, and check
state.facingfromonCameraStateChangedto see what the camera actually settled on
Switching stops working once a lens is pinned
- On Android, a facing switch drops
pinnedLensIdback to Auto; a resolved pin also overridescameraFacingand moves the camera to the pinned lens's facing - Drive one control or the other, not both - see Camera Controls
Brief preview gap during switch on Android
- Expected - Android rebuilds the camera session for the new facing
- Do not add your own
stop()/start()around the switch; that competes with the rebuild
Camera feed freezes during switch
- This shouldn't happen on iOS - report as a bug
- Ensure you're not stopping/starting the camera during switch
Flash doesn't work on front camera
- Most devices don't have front-facing flash
- Consider adding a white screen flash effect for selfies
Related Documentation
- VisionCamera Component - Full VisionCamera documentation
- Props Reference - Complete props documentation