React Native apps can access native device features through Expo modules and community libraries.

AsyncStorage — Local Persistence

Store key-value data on the device:

  npx expo install @react-native-async-storage/async-storage
  
  import AsyncStorage from '@react-native-async-storage/async-storage';

// Save
await AsyncStorage.setItem('token', 'abc123');

// Read
const token = await AsyncStorage.getItem('token');

// Remove
await AsyncStorage.removeItem('token');

// Store objects
await AsyncStorage.setItem('user', JSON.stringify({ name: 'Jane' }));
const user = JSON.parse(await AsyncStorage.getItem('user'));
  

Camera

  npx expo install expo-camera
  
  import { CameraView, useCameraPermissions } from 'expo-camera';

function CameraScreen() {
    const [permission, requestPermission] = useCameraPermissions();

    if (!permission?.granted) {
        return (
            <View>
                <Text>Camera permission required</Text>
                <Button title="Grant Permission" onPress={requestPermission} />
            </View>
        );
    }

    return <CameraView style={{ flex: 1 }} facing="back" />;
}
  

Image Picker

Select photos from the library or take new ones:

  npx expo install expo-image-picker
  
  import * as ImagePicker from 'expo-image-picker';

async function pickImage() {
    const result = await ImagePicker.launchImageLibraryAsync({
        mediaTypes: ['images'],
        allowsEditing: true,
        quality: 0.8,
    });

    if (!result.canceled) {
        return result.assets[0].uri;
    }
}
  

Location

  npx expo install expo-location
  
  import * as Location from 'expo-location';

async function getLocation() {
    const { status } = await Location.requestForegroundPermissionsAsync();
    if (status !== 'granted') return null;

    const location = await Location.getCurrentPositionAsync({});
    return {
        latitude: location.coords.latitude,
        longitude: location.coords.longitude,
    };
}
  

Platform Detection

  import { Platform } from 'react-native';

if (Platform.OS === 'ios') {
    // iOS-specific code
} else if (Platform.OS === 'android') {
    // Android-specific code
}

const version = Platform.Version; // OS version number
  

Browse available APIs at docs.expo.dev. Install with npx expo install <package>.

Next: optimize your app for smooth performance.