React Native Device Information
react-native-device-info is a comprehensive library for React Native applications that provides access to various device-specific information across iOS, Android, and Windows platforms. It allows developers to retrieve details such as device unique ID, brand, model, OS version, system name, application build number, and more. The current stable version is 15.0.2, released in early 2026. The package maintains a frequent release cadence, often issuing multiple patch and minor versions monthly, with major versions typically arriving a few times a year, indicating active development and timely updates for new device capabilities and platform changes. Its key differentiators include broad platform support, a rich API covering a wide range of device properties, and a commitment to keeping up with the latest React Native and platform SDK versions, which sometimes introduces breaking changes related to compilation targets or permissions.
Common errors
-
RNDeviceInfo is null
cause The native module for react-native-device-info was not correctly linked or initialized by React Native.fixEnsure your React Native project is correctly set up for autolinking (React Native >= 0.63). If you are on an older version or using a specific setup, manually verify all linking steps for iOS, Android, and other platforms. Consider running `npx react-native doctor` for diagnostics. -
Program type already present: com.google.android.gms.common.api.internal.zzb
cause Duplicate or conflicting Google Play Services dependencies in your Android project's `build.gradle` files.fixReview your `android/build.gradle` files (root and app level) for multiple versions or conflicting inclusions of Google Play Services libraries. Use `gradlew :app:dependencies` to identify duplicates and exclude them if necessary. -
A problem occurred evaluating project ':react-native-device-info'. > Requires compileSdk 34+
cause Your project's `compileSdkVersion` in `android/build.gradle` is lower than 34 after upgrading react-native-device-info to v15.x.fixUpdate `compileSdkVersion` in your `android/build.gradle` file to at least 34. For example: `ext { compileSdkVersion = 34 }`. -
java.lang.NullPointerException: Attempt to invoke virtual method '...' on a null object reference (related to hasKeyboard)
cause This specific NullPointerException occurred in earlier versions (pre-14.1.1) of the library on Android when calling the `hasKeyboard` function.fixUpgrade `react-native-device-info` to version 14.1.1 or higher to resolve the NullPointerException in the `hasKeyboard` function on Android.
Warnings
- breaking Upgrading to v15.0.0 requires your Android project to use 'compileSdk 34' or higher. Applications targeting lower API levels will fail to build.
- breaking Version 14.0.0 removed the automatic addition of the AD_ID permission by discontinuing the auto-addition of 'play-services-iid'. This may affect features relying on this permission.
- breaking Version 7.x introduced a minimum iOS deployment target of 10. Applications targeting iOS 9 or lower will no longer be supported.
- gotcha The module defaults to AndroidX. If your project does not use AndroidX, you will need to configure `jetifier` in reverse mode or upgrade your project.
- gotcha When using Proguard/R8 in release builds, you must add specific rules to prevent issues with features like Install Referrer tracking or `hasGms()` detection, which might be stripped otherwise.
- gotcha New React Native developers often encounter 'RNDeviceInfo is null' errors due to incorrect native module linking. While automatic linking is supported for modern RN versions, manual steps or project misconfigurations can cause this.
Install
-
npm install react-native-device-info -
yarn add react-native-device-info -
pnpm add react-native-device-info
Imports
- DeviceInfo
import { DeviceInfo } from 'react-native-device-info';import DeviceInfo from 'react-native-device-info';
- getUniqueId
import DeviceInfo from 'react-native-device-info'; const getUniqueId = DeviceInfo.getUniqueId;
import { getUniqueId } from 'react-native-device-info'; - getManufacturer
const { getManufacturer } = require('react-native-device-info');import { getManufacturer } from 'react-native-device-info'; - DeviceType
import type { DeviceType } from 'react-native-device-info';
Quickstart
import DeviceInfo, {
getUniqueId,
getManufacturer,
getSystemName,
getSystemVersion,
isTablet,
getApplicationName,
getVersion,
getBuildNumber
} from 'react-native-device-info';
import { View, Text, StyleSheet } from 'react-native';
import React from 'react';
const App = () => {
const [deviceDetails, setDeviceDetails] = React.useState({});
React.useEffect(() => {
async function fetchDeviceInfo() {
const uniqueId = await getUniqueId();
const manufacturer = await getManufacturer();
const systemName = getSystemName();
const systemVersion = getSystemVersion();
const isTabletDevice = isTablet();
const appName = getApplicationName();
const appVersion = getVersion();
const buildNumber = getBuildNumber();
setDeviceDetails({
uniqueId,
manufacturer,
systemName,
systemVersion,
isTablet: isTabletDevice,
appName,
appVersion,
buildNumber,
deviceBrand: DeviceInfo.getBrand(),
model: DeviceInfo.getModel(),
hasNotch: DeviceInfo.hasNotch(),
});
}
fetchDeviceInfo();
}, []);
return (
<View style={styles.container}>
<Text style={styles.header}>Device Information:</Text>
{Object.entries(deviceDetails).map(([key, value]) => (
<Text key={key} style={styles.detailText}>
{key}: {String(value)}
</Text>
))}
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
padding: 20,
backgroundColor: '#f0f0f0',
},
header: {
fontSize: 24,
fontWeight: 'bold',
marginBottom: 20,
color: '#333',
},
detailText: {
fontSize: 16,
marginBottom: 5,
color: '#555',
},
});
export default App;