This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Expo Camera
A React component that renders a preview for the device's front or back camera.
expo-camera provides a React component that renders a preview of the device's front or back camera. The camera's parameters such as zoom, torch, and flash mode are adjustable. Using CameraView, you can take photos and record videos that are saved to the app's cache. The component is also capable of detecting bar codes appearing in the preview. Run the example on your device to see all these features working together.
Installation
If you are installing this in an existing React Native app, make sure to install expo in your project.
Configuration in app config
You can configure expo-camera using its built-in config plugin if you use config plugins in your project (Continuous Native Generation (CNG)). The plugin allows you to configure various properties that cannot be set at runtime and require building a new app binary to take effect. If your app does not use CNG, then you'll need to manually configure the library.
Example app.json with config plugin
Configurable properties
Are you using this library in an existing React Native app?
If you're not using Continuous Native Generation (CNG) (you're using native android and ios projects manually), then you need to configure following permissions in your native projects:
Android
-
expo-cameraautomatically addsandroid.permission.CAMERApermission to your project's android/app/src/main/AndroidManifest.xml. If you want to record videos with audio, includeRECORD_AUDIOpermission:<!-- Added permission --> <uses-permission android:name="android.permission.CAMERA" /> <!-- Only add when recording videos with audio --> <uses-permission android:name="android.permission.RECORD_AUDIO" /> -
Then, adjust the android/build.gradle file to add new maven block after all other repositories as show below:
allprojects { repositories { // * Your other repositories here * // * Add a new maven block after other repositories / blocks * maven { // expo-camera bundles a custom com.google.android:cameraview url "$rootDir/../node_modules/expo-camera/android/maven" } } }
iOS
-
Add
NSCameraUsageDescriptionandNSMicrophoneUsageDescriptionkeys to your project's ios/[app]/Info.plist:<key>NSCameraUsageDescription</key> <string>Allow $(PRODUCT_NAME) to access your camera</string> <key>NSMicrophoneUsageDescription</key> <string>Allow $(PRODUCT_NAME) to access your microphone</string>
Usage
Only one Camera preview can be active at any given time. If you have multiple screens in your app, you should unmount
Cameracomponents whenever a screen is unfocused.
Advanced usage
A complete example that shows how to take a picture and display it. Written in TypeScript.
Web support
Most browsers support a version of web camera functionality, you can check out the web camera browser support here. Image URIs are always returned as base64 strings because local file system paths are unavailable in the browser.
Chrome iframe usage
When using Chrome versions 64+, if you try to use a web camera in a cross-origin iframe nothing will render. To add support for cameras in your iframe simply add the attribute allow="microphone; camera;" to the iframe element:
<iframe src="..." allow="microphone; camera;"> <!-- <CameraView /> --> </iframe>
API
import { CameraView } from 'expo-camera';
No API data file found, sorry!
Permissions
Android
This package automatically adds the CAMERA permission to your app. If you want to record videos with audio, you have to include the RECORD_AUDIO in your app.json inside the expo.android.permissions array.
iOS
The following usage description keys are used by this library: