Registry / react-native-vision-camera

react-native-vision-camera

JSON →
library5.0.1jsnpmunverified

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-camera
INSTALL
IMPORT
SIG · REACT-NATIVE-VISIO
R
react-native-vision-camera
javascriptv5.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Camera
import { Camera } from 'react-native-vision-camera'
const Camera = require('react-native-vision-camera')
VisionCamera is primarily designed for ES Modules and React Functional Components. CommonJS `require` is not recommended.
useCameraDevice
import { useCameraDevice } from 'react-native-vision-camera'
This hook provides access to available camera devices (e.g., 'back', 'front').
useCameraPermission
import { useCameraPermission } from 'react-native-vision-camera'
Essential hook for checking and requesting camera permissions.
useFrameProcessor
import { useFrameProcessor } from 'react-native-vision-camera'
Used for defining custom C++ frame processing functions with JSI.

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.

import React, { useEffect } from 'react'; import { View, Text, StyleSheet, Linking, Alert } from 'react-native'; import { Camera, useCameraDevice, useCameraPermission } from 'react-native-vision-camera'; const App = () => { const { hasPermission, requestPermission } = useCameraPermission(); const device = useCameraDevice('back'); useEffect(() => { if (!hasPermission) { requestPermission().then(granted => { if (!granted) { Alert.alert( 'Permission Required', 'Camera access is required to use this feature. Please enable it in settings.', [ { text: 'Cancel', style: 'cancel' }, { text: 'Open Settings', onPress: () => Linking.openSettings() } ] ); } }); } }, [hasPermission, requestPermission]); if (!hasPermission) { return <Text style={styles.permissionText}>Requesting Camera Permission...</Text>; } if (device == null) { return <Text style={styles.permissionText}>No Camera Device Found.</Text>; } return ( <View style={styles.container}> <Camera style={StyleSheet.absoluteFill} device={device} isActive={true} photo={true} // Enable photo capture video={true} // Enable video capture // frameProcessor={frameProcessor} // Uncomment for custom frame processing // frameProcessorFps={30} // Set frame processor FPS /> </View> ); }; const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: 'black', }, permissionText: { flex: 1, color: 'white', textAlign: 'center', textAlignVertical: 'center', fontSize: 18, }, }); export default App;
Debug
Known issues
breakingVisionCamera v5.0.0 is a complete rewrite based on 'Nitro Modules' and introduces a new 'Constraints API'. Migration from v4 will require significant code changes, including updating imports, camera configuration, and potentially adapting to new APIs for frame processing and other features. Ensure `react-native-nitro-modules` and `react-native-nitro-image` are installed.
fix
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.
affects: >=5.0.0
breakingThe `videoBitRate` prop was moved from `startRecording({ ... })` options to a direct prop on the `<Camera />` component in v4.6.0. This change was made to enable Android support for `videoBitRate`.
fix
Migrate `videoBitRate` from the `startRecording` options object to a prop directly on the `<Camera />` component: `<Camera videoBitRate={5000000} />`.
affects: >=4.6.0
gotchaCamera permissions must be explicitly added to your application's `Info.plist` (iOS) and `AndroidManifest.xml` (Android) files. The library cannot function without these native manifest entries.
fix
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.
affects: >=1.0.0
gotchaLinking native modules properly is crucial. Issues often arise from incorrect `pod install` or Android project configuration after installing the package or upgrading React Native.
fix
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.
affects: >=1.0.0
gotchaCertain devices might not load camera devices correctly on app start, leading to a `No Camera Device Found` error or similar initialization exceptions.
fix
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).
affects: >=4.7.1
Errors
Common errors & fixes
Invariant Violation: 'RCTVisionCamera' could not be found. Are you sure 'react-native-vision-camera' is installed and linked correctly?
Native module not linked or found. Common after `npm install` without rebuilding native projects, or during React Native upgrades.
fix
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`.
Error: Permission denied. Make sure to request Camera permission.
The application does not have the necessary camera permissions from the user or the `AndroidManifest.xml`/`Info.plist` entries are missing.
fix
Use `useCameraPermission()` hook to request permissions at runtime and ensure the correct permission declarations are present in `AndroidManifest.xml` (Android) and `Info.plist` (iOS).
Undefined symbol: _OBJC_CLASS_$_VisionCameraView
iOS linker error, typically indicating that the VisionCamera framework is not correctly linked or embedded.
fix
Ensure `npx pod-install` has been run and Xcode project settings correctly link the `VisionCamera` framework. Clean Xcode build folder and rebuild.
Could not find `react-native-nitro-modules` (or `react-native-nitro-image`) in `node_modules`.
VisionCamera v5.0.0+ has new peer dependencies that must be explicitly installed.
fix
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.
Upgrade
Version history
5.0.1latest on npm
Audit
Dependencies
reactrequiredPeer dependency for React Native components.
react-nativerequiredCore React Native dependency.
react-native-nitro-modulesrequiredRequired for VisionCamera v5+ due to architectural rewrite.
react-native-nitro-imagerequiredRequired for VisionCamera v5+ for image handling.
Agent activity
10 hits · last 30 days
node
10
Resources
react-native-vision-camera — npm install react-native-vision-camera · libregistry