React Native Expo Camera | Tutorial
Beto, August 4, 2023 · 8,396 views
Learn how to integrate the camera in a React Native app with Expo. I cover requesting camera and media library permissions, taking photos with flash, and switching between front and back cameras. Ideal if you want camera features in Expo apps.
I also explain saving photos to the device and basic state for camera, flash, and captured images. Code and dependencies are included so you can replicate the project.
What's inside
- Introduction and camera app demo
- Expo project installation and setup
- Requesting camera and media library permissions
- State variables for camera, flash, and image
- Camera component configuration with props and ref
- Taking photos, toggling flash, and switching cameras
- Saving photos to the library and showing alerts
- Retake or save options after capture
Introduction and camera app demo
The demo runs on a real device: capture button, flash toggle, front/back switch, retake, and save to gallery.
It shows what you can build with Expo Camera and what the UX feels like.
Expo project installation and setup
Create a project with and the blank template. Install and .
Run and open the project in Visual Studio Code before adding camera code.
Requesting camera and media library permissions
The app requests permissions with and .
A requests permissions on mount. tracks the user's response.
State variables for camera, flash, and image
manages:
- : whether permissions were granted
- : URI of the captured photo
- : front or back camera ( or )
- : flash mode ( or )
holds the camera instance for capture.
Camera component configuration with props and ref
The component receives:
- for full screen
- for active camera
- for flash state
- for the camera reference
State drives these props as the user interacts.
Taking photos, toggling flash, and switching cameras
Buttons:
- Capture with via the ref
- Toggle flash by updating state
- Switch cameras by updating state
The photo URI goes into state for preview or save.
Saving photos to the library and showing alerts
Save to the gallery with . Show an alert on success.
Console logs help during development.
Retake or save options after capture
Users can retake if they are not happy with the shot, or save to the library with confirmation.
Basic flow control that improves the capture experience.
Resources

CourseReact Native course
React Native fundamentals from basics through deployment.

YouTubeReact Native Camera Tutorial
Step-by-step video on using the camera in React Native with Expo.
Like this article? Get the rest of the library plus weekly React Native tips. Free.