expo-device
Version: 55.0.7
A universal module that gets physical information about the device running the application.
Installation
npx expo install expo-device
Usage
import * as Device from 'expo-device';
console.log(Device.modelName); // "iPhone 14 Pro"
console.log(Device.osVersion); // "16.0"
console.log(Device.deviceType); // Device.DeviceType.PHONE
API Reference
Properties
Device brand (e.g., “Apple”, “Samsung”)
Device model name (e.g., “iPhone 14 Pro”, “Pixel 7”)
Internal model identifier
Approximate year the device was released
Total device memory in bytes
Device.supportedCpuArchitectures
Supported CPU architectures (e.g., [“arm64”, “armv7”])
OS name (“iOS”, “Android”, etc.)
Internal OS build identifier
Android only: Android API level
User-assigned device name (e.g., “John’s iPhone”)
Type of device:
Device.DeviceType.PHONE
Device.DeviceType.TABLET
Device.DeviceType.DESKTOP
Device.DeviceType.TV
Device.DeviceType.UNKNOWN
Methods
Device.getDeviceTypeAsync()
() => Promise<DeviceType>
Asynchronously gets device typeconst deviceType = await Device.getDeviceTypeAsync();
Device.isRootedExperimentalAsync()
Experimental: Checks if device is rooted/jailbrokenconst isRooted = await Device.isRootedExperimentalAsync();
Device.isSideLoadingEnabledAsync()
Android only: Checks if side-loading is enabled
Device.getPlatformFeaturesAsync()
Android only: Gets list of supported platform features
Device.hasPlatformFeatureAsync(feature)
(feature: string) => Promise<boolean>
Android only: Checks if device supports a specific featureconst hasNFC = await Device.hasPlatformFeatureAsync(
'android.hardware.nfc'
);
Device.getMaxMemoryAsync()
Gets maximum available memory in bytes
Examples
Display Device Info
import * as Device from 'expo-device';
import { Text, View } from 'react-native';
function DeviceInfo() {
return (
<View>
<Text>Brand: {Device.brand}</Text>
<Text>Model: {Device.modelName}</Text>
<Text>OS: {Device.osName} {Device.osVersion}</Text>
<Text>Device Type: {
Device.deviceType === Device.DeviceType.PHONE ? 'Phone' :
Device.deviceType === Device.DeviceType.TABLET ? 'Tablet' :
'Unknown'
}</Text>
<Text>Memory: {(Device.totalMemory / 1024 / 1024 / 1024).toFixed(2)} GB</Text>
</View>
);
}
Check Device Capabilities
import * as Device from 'expo-device';
import { Platform } from 'react-native';
async function checkCapabilities() {
const deviceType = await Device.getDeviceTypeAsync();
const isTablet = deviceType === Device.DeviceType.TABLET;
if (Platform.OS === 'android') {
const hasNFC = await Device.hasPlatformFeatureAsync(
'android.hardware.nfc'
);
console.log('NFC Support:', hasNFC);
}
const maxMemory = await Device.getMaxMemoryAsync();
console.log('Max Memory:', maxMemory);
}
Responsive Layout Based on Device
import * as Device from 'expo-device';
import { View, StyleSheet } from 'react-native';
function ResponsiveLayout({ children }) {
const isTablet = Device.deviceType === Device.DeviceType.TABLET;
return (
<View style={[
styles.container,
isTablet && styles.tabletContainer
]}>
{children}
</View>
);
}
const styles = StyleSheet.create({
container: { padding: 16 },
tabletContainer: { padding: 32, maxWidth: 1024 }
});
| Platform | Supported |
|---|
| iOS | ✅ |
| Android | ✅ |
| Web | ✅ |
Resources