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 iconExpo Camera

A React component that renders a preview for the device's front or back camera.

Android (device only)
iOS (device only)
Web
Included in Expo Go
Recommended version:
~56.0.8

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

Terminal
- npx expo install expo-camera
- yarn expo install expo-camera
- pnpm expo install expo-camera
- bun expo install expo-camera

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

app.json
{ "expo": { "plugins": [ [ "expo-camera", { "cameraPermission": "Allow $(PRODUCT_NAME) to access your camera", "microphonePermission": "Allow $(PRODUCT_NAME) to access your microphone", "recordAudioAndroid": true, "barcodeScannerEnabled": true } ] ] } }

Configurable properties

NameDefaultDescription
cameraPermission"Allow $(PRODUCT_NAME) to access your camera"
Only for: 
iOS

A string to set the NSCameraUsageDescription permission message.

microphonePermission"Allow $(PRODUCT_NAME) to access your microphone"
Only for: 
iOS

A string to set the NSMicrophoneUsageDescription permission message.

recordAudioAndroidtrue
Only for: 
Android

A boolean that determines whether to enable the RECORD_AUDIO permission on Android.

barcodeScannerEnabledtrue

A boolean that determines whether to enable barcode scanning support. Disabling this reduces app size when barcode scanning is not needed.

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-camera automatically adds android.permission.CAMERA permission to your project's android/app/src/main/AndroidManifest.xml. If you want to record videos with audio, include RECORD_AUDIO permission:

    <!-- 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 NSCameraUsageDescription and NSMicrophoneUsageDescription keys 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

Basic Camera Usage
import { CameraView, CameraType, useCameraPermissions } from 'expo-camera'; import { useState } from 'react'; import { Button, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; export default function App() { const [facing, setFacing] = useState<CameraType>('back'); const [permission, requestPermission] = useCameraPermissions(); if (!permission) { // Camera permissions are still loading. return <View />; } if (!permission.granted) { // Camera permissions are not granted yet. return ( <View style={styles.container}> <Text style={styles.message}>We need your permission to show the camera</Text> <Button onPress={requestPermission} title="grant permission" /> </View> ); } function toggleCameraFacing() { setFacing(current => (current === 'back' ? 'front' : 'back')); } return ( <View style={styles.container}> <CameraView style={styles.camera} facing={facing} /> <View style={styles.buttonContainer}> <TouchableOpacity style={styles.button} onPress={toggleCameraFacing}> <Text style={styles.text}>Flip Camera</Text> </TouchableOpacity> </View> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', }, message: { textAlign: 'center', paddingBottom: 10, }, camera: { flex: 1, }, buttonContainer: { position: 'absolute', bottom: 64, flexDirection: 'row', backgroundColor: 'transparent', width: '100%', paddingHorizontal: 64, }, button: { flex: 1, alignItems: 'center', }, text: { fontSize: 24, fontWeight: 'bold', color: 'white', }, });

Advanced usage

Camera app example

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.

Android permissionDescription

CAMERA

Required to be able to access the camera device.

RECORD_AUDIO

Allows an application to record audio.

iOS

The following usage description keys are used by this library:

Info.plist keyDescription

NSCameraUsageDescription

A message that tells the user why the app is requesting access to the device’s camera.

NSMicrophoneUsageDescription

A message that tells the user why the app is requesting access to the device’s microphone.