react-native-pro-camera
v1.3.0
Published
An elegant, high-performance camera library for React Native powered by CameraX and AVFoundation. Features zero-config installation, automatic permissions, native tap-to-focus, flash toggle, grid overlays, and instantaneous photo capture.
Maintainers
Readme
react-native-pro-camera
A high-performance camera library for React Native built with CameraX (Android) and AVFoundation (iOS).
Features
- Android & iOS support
- React Native New Architecture
- React Native Old Architecture
- Ready-to-use camera screen
- Custom camera view
- Tap to focus
- Flash control
- Front & back camera
- Photo preview
- Save to gallery support
Installation
npm install react-native-pro-camera react-native-svg react-native-safe-area-contextor
yarn add react-native-pro-camera react-native-svg react-native-safe-area-contextNote
react-native-svgandreact-native-safe-area-contextare required peer dependencies.
iOS Setup
Install CocoaPods:
cd ios
pod install
cd ..Add the following permission to Info.plist:
<key>NSCameraUsageDescription</key>
<string>This app requires camera access to capture photos.</string>Android Setup
No manual setup is required.
Recommended Lock your app to portrait mode to avoid preview rotation issues.
<activity
android:name=".MainActivity"
android:screenOrientation="portrait" />Usage
Ready-to-use Camera
import { ProCameraScreen } from "react-native-pro-camera";
export default function App() {
return (
<ProCameraScreen
showPreviewOnCapture
saveToPhotos={false}
initialLensFacing="back"
initialFlashMode="off"
onPhotoCaptured={(photo) => {
console.log(photo);
}}
/>
);
}Custom Camera
import { useRef } from "react";
import {
ProCameraView,
checkPermissions,
requestPermissions,
} from "react-native-pro-camera";
const cameraRef = useRef(null);
async function capture() {
const photo = await cameraRef.current?.takePicture({
saveToPhotos: false,
});
console.log(photo);
}
<ProCameraView
ref={cameraRef}
style={{ flex: 1 }}
/>;API
Methods
| Method | Description |
|---------|-------------|
| checkPermissions() | Check camera permission. |
| requestPermissions() | Request camera permission. |
| takePicture(options?) | Capture a photo. |
takePicture()
takePicture({
saveToPhotos?: boolean;
});Photo Result
{
uri: string;
path: string;
width: number;
height: number;
mediaStoreUri?: string;
}ProCameraScreen Props
| Prop | Default |
|------|---------|
| showPreviewOnCapture | false |
| saveToPhotos | false |
| initialLensFacing | "back" |
| initialFlashMode | "off" |
| onPhotoCaptured | - |
| onError | - |
ProCameraView Props
| Prop | Default |
|------|---------|
| lensFacing | "back" |
| flashMode | "off" |
| onFocusTap | - |
| onError | - |
License
MIT
