Get device information using react-native
npx @tessl/cli install tessl/npm-react-native-device-info@14.0.0React Native Device Info is a comprehensive cross-platform library that provides access to device and system information across iOS, Android, Windows, and web platforms. It offers a rich API for retrieving device details including hardware specifications, system information, unique identifiers, battery status, network information, and device capabilities with both synchronous and asynchronous data retrieval patterns.
npm install react-native-device-infoimport DeviceInfo from 'react-native-device-info';
// Or ES6+ destructured imports
import {
getUniqueId,
getManufacturer,
getBatteryLevel,
isTablet,
useBatteryLevel
} from 'react-native-device-info';For CommonJS:
const DeviceInfo = require('react-native-device-info');
// Or destructured
const { getUniqueId, getManufacturer } = require('react-native-device-info');import {
getUniqueId,
getManufacturer,
getBatteryLevel,
isTablet,
getSystemVersion
} from 'react-native-device-info';
// Basic device identification
const deviceId = await getUniqueId();
const manufacturer = await getManufacturer();
const isTabletDevice = isTablet();
// System information
const osVersion = getSystemVersion();
// Battery status
const batteryLevel = await getBatteryLevel();
console.log(`Device: ${manufacturer} (${deviceId})`);
console.log(`OS Version: ${osVersion}`);
console.log(`Device Type: ${isTabletDevice ? 'Tablet' : 'Phone'}`);
console.log(`Battery: ${Math.round(batteryLevel * 100)}%`);React Native Device Info is built around several key architectural components:
Core device identification functionality for retrieving unique identifiers, device details, and hardware information. Essential for analytics, device tracking, and platform-specific behavior.
function getUniqueId(): Promise<string>;
function getUniqueIdSync(): string;
function getDeviceId(): string;
function getModel(): string;
function getBrand(): string;
function getManufacturer(): Promise<string>;
function getManufacturerSync(): string;System and operating system information including OS version, build details, and platform-specific system properties. Critical for compatibility checks and platform-specific feature detection.
function getSystemName(): string;
function getSystemVersion(): string;
function getBuildId(): Promise<string>;
function getBuildIdSync(): string;
function getApiLevel(): Promise<number>; // Android only
function getApiLevelSync(): number; // Android only
function supportedAbis(): Promise<string[]>;
function supportedAbisSync(): string[];
function hasSystemFeature(feature: string): Promise<boolean>; // Android only
function hasSystemFeatureSync(feature: string): boolean; // Android only
function getStartupTime(): Promise<number>;
function getStartupTimeSync(): number;Application metadata including version information, installation details, and app-specific identifiers. Useful for app analytics, version checking, and installation tracking.
function getApplicationName(): string;
function getBundleId(): string;
function getVersion(): string;
function getBuildNumber(): string;
function getReadableVersion(): string;
function getFirstInstallTime(): Promise<number>;
function getFirstInstallTimeSync(): number;Memory usage and storage capacity information for performance monitoring and storage management. Essential for optimizing app performance and managing device resources.
function getUsedMemory(): Promise<number>;
function getUsedMemorySync(): number;
function getTotalMemory(): Promise<number>;
function getTotalMemorySync(): number;
function getFreeDiskStorage(): Promise<number>;
function getFreeDiskStorageSync(): number;
function getTotalDiskCapacity(): Promise<number>;
function getTotalDiskCapacitySync(): number;Battery status and power management information for power-aware applications and battery optimization. Critical for apps that need to adapt behavior based on battery state.
function getBatteryLevel(): Promise<number>;
function getBatteryLevelSync(): number;
function getPowerState(): Promise<Partial<PowerState>>;
function getPowerStateSync(): Partial<PowerState>;
function isBatteryCharging(): Promise<boolean>;
function isBatteryChargingSync(): boolean;
interface PowerState {
batteryLevel: number;
batteryState: BatteryState;
lowPowerMode: boolean;
[key: string]: any;
}
type BatteryState = 'unknown' | 'unplugged' | 'charging' | 'full';Network and connectivity information including IP addresses, carrier information, and connection status. Important for network-aware applications and connectivity debugging.
function getIpAddress(): Promise<string>;
function getIpAddressSync(): string;
function getCarrier(): Promise<string>;
function getCarrierSync(): string;
function getMacAddress(): Promise<string>;
function getMacAddressSync(): string;
function isAirplaneMode(): Promise<boolean>;
function isAirplaneModeSync(): boolean;Hardware feature detection and capability checking for cameras, audio devices, input peripherals, and platform-specific hardware. Essential for feature-dependent applications.
function isCameraPresent(): Promise<boolean>;
function isCameraPresentSync(): boolean;
function isHeadphonesConnected(): Promise<boolean>;
function isHeadphonesConnectedSync(): boolean;
function hasNotch(): boolean;
function hasDynamicIsland(): boolean;
function isTablet(): boolean;
function isEmulator(): Promise<boolean>;
function isEmulatorSync(): boolean;Real-time monitoring hooks for dynamic device states and event-driven updates. Perfect for React components that need to respond to device state changes automatically.
function useBatteryLevel(): number | null;
function usePowerState(): Partial<PowerState>;
function useDeviceName(): AsyncHookResult<string>;
function useIsHeadphonesConnected(): AsyncHookResult<boolean>;
function useBrightness(): number | null;
interface AsyncHookResult<T> {
loading: boolean;
result: T;
}type DeviceType = 'Handset' | 'Tablet' | 'Tv' | 'Desktop' | 'GamingConsole' | 'unknown';
type BatteryState = 'unknown' | 'unplugged' | 'charging' | 'full';
type AvailableCapacityType = 'total' | 'important' | 'opportunistic';
interface PowerState {
batteryLevel: number;
batteryState: BatteryState;
lowPowerMode: boolean;
[key: string]: any;
}
interface LocationProviderInfo {
[key: string]: boolean;
}
interface AsyncHookResult<T> {
loading: boolean;
result: T;
}