This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Use an image picker
Edit page
In this tutorial, learn how to use Expo Image Picker.
React Native provides built-in components as standard building blocks, such as <View>, <Text>, and <Pressable>. We are building a feature to select an image from the device's media gallery. This isn't possible with the core components and we'll need a library to add this feature in our app.
We'll use expo-image-picker, a library from Expo SDK.
expo-image-pickerprovides access to the system's UI to select images and videos from the phone's library.

Learn how to use expo-image-picker to select images from the device's media library.
1
Install expo-image-picker
To install the expo-image-picker library, stop the development server by pressing Ctrl + C in the terminal, then run the following command:
The npx expo install command will install the library and add it to the project's dependencies in package.json.
Tip: Any time we install a new library in the project, stop the development server by pressing Ctrl + C in the terminal and then run the installation command. After the installation completes, start the development server again by running
npx expo start.
2
Pick an image from the device's media library
expo-image-picker provides launchImageLibraryAsync() method to display the system UI by choosing an image or a video from the device's media library. We'll use the primary themed button created in the previous chapter to select an image from the device's media library and create a function to launch the device's image library to implement this functionality.
In src/app/(tabs)/index.tsx, import expo-image-picker library and create a pickImageAsync() function inside the Index component:
Let's learn what the above code does:
- The
launchImageLibraryAsync()receives an object to specify different options. This object is theImagePickerOptionsobject, which we are passing when invoking the method. - When
allowsEditingis set totrue, the user can crop the image during the selection process on Android and iOS.
3
Update the button component
On pressing the primary button, we'll call the pickImageAsync() function on the Button component. Update the onPress prop of the Button component in src/components/button.tsx:
In src/app/(tabs)/index.tsx, add the pickImageAsync() function to the onPress prop on the first <Button>.
The pickImageAsync() function invokes ImagePicker.launchImageLibraryAsync() and then handles the result. The launchImageLibraryAsync() method returns an object containing information about the selected image.
Here is an example of the result object and the properties it contains: