VisionCamera is a high-performance, feature-rich camera library for React Native, currently at version 5.0.1. It provides direct access to camera hardware, supporting advanced features like custom frame processing (via C++ JSI) and granular control over camera devices and capabilities. Version 5.0.0 marked a significant rewrite, building upon 'Nitro Modules' and introducing a new 'Constraints API' for more flexible camera configuration. The library maintains a regular release cadence, with frequent patch updates addressing bugs and minor features within major versions, and new major versions (like v5) introducing substantial architectural changes. Its key differentiators include superior performance, direct native control, and advanced customization options not typically found in simpler camera abstractions.
npm install react-native-vision-cameraVerified import paths — ran on the pinned version, not inferred.
This code snippet demonstrates requesting camera permissions and rendering a basic camera preview using the back camera. It includes checks for permissions and device availability.
Refer to the official VisionCamera v5 deep-dive blog post and new documentation at `blog.margelo.com/whats-new-in-visioncamera-v5` and `visioncamera.margelo.com` for detailed migration instructions and new API usage.
Migrate `videoBitRate` from the `startRecording` options object to a prop directly on the `<Camera />` component: `<Camera videoBitRate={5000000} />`.Follow the official installation guide to add `NSCameraUsageDescription` and `NSMicrophoneUsageDescription` (for video) to `Info.plist` on iOS, and `android.permission.CAMERA` and `android.permission.RECORD_AUDIO` to `AndroidManifest.xml` on Android.
After `npm install`, ensure `npx pod-install` is run for iOS. For Android, rebuild your app and clear Gradle caches if encountering linking errors. Check `react-native.config.js` for auto-linking issues.
Implement robust error handling and fallback UI for when `useCameraDevice` returns `null`. Check for library updates, as fixes for such issues are frequently released (e.g., v4.7.1 addressed a case where no camera devices were loaded on app start).
Run `npx pod-install` in your iOS directory and rebuild your app for both platforms. Ensure `react-native-vision-camera` is properly added to `package.json` and `node_modules`.
Use `useCameraPermission()` hook to request permissions at runtime and ensure the correct permission declarations are present in `AndroidManifest.xml` (Android) and `Info.plist` (iOS).
Ensure `npx pod-install` has been run and Xcode project settings correctly link the `VisionCamera` framework. Clean Xcode build folder and rebuild.
Install the required peer dependencies: `npm install react-native-nitro-modules react-native-nitro-image` and then run `npx pod-install` and rebuild your app.