Skip to main content
The Platform module provides information about the platform the app is running on. Use it to implement platform-specific behavior and conditionally render components.

Import

Properties

OS

Returns the current operating system.
Returns: 'ios' | 'android' | 'windows' | 'macos' | 'web'

Version

Returns the OS version.
Returns:
  • iOS: string - iOS version (e.g., '16.0')
  • Android: number - API level (e.g., 33)

constants

Object containing platform-specific constants.
iOS constants:
  • forceTouchAvailable (boolean): Whether 3D Touch is available
  • interfaceIdiom (string): Device type ('phone', 'pad', 'tv', 'vision')
  • isTesting (boolean): Whether running in test mode
  • isDisableAnimations (boolean): Whether animations are disabled
  • osVersion (string): iOS version
  • systemName (string): OS name (e.g., 'iOS')
  • isMacCatalyst (boolean): Whether running on Mac Catalyst
  • reactNativeVersion (object): React Native version info
Android constants:
  • Version (number): Android API level
  • Release (string): Android release version
  • Serial (string): Device serial number
  • Fingerprint (string): Build fingerprint
  • Model (string): Device model
  • Brand (string): Device brand
  • Manufacturer (string): Device manufacturer
  • ServerHost (string): Development server host (debug builds)
  • uiMode (string): UI mode ('normal', 'tv', etc.)
  • isTesting (boolean): Whether running in test mode
  • isDisableAnimations (boolean): Whether animations are disabled
  • reactNativeVersion (object): React Native version info

isPad (iOS only)

Whether the device is an iPad.
Returns: boolean

isTV

Whether the device is a TV (Apple TV or Android TV).
Returns: boolean

isVision (iOS only)

Whether the device is Apple Vision Pro.
Returns: boolean

isTesting

Whether the app is running in test mode.
Returns: boolean

isDisableAnimations

Whether animations are disabled (for testing or accessibility).
Returns: boolean

isMacCatalyst (iOS only)

Whether the app is running on Mac via Catalyst.
Returns: boolean

Methods

select()

Returns the appropriate value for the current platform.
object
required
Object with platform-specific values:
The method checks keys in order: ios/android → native → default
Returns: The value for the current platform.

Examples

Basic Platform Detection

Conditional Rendering

Using Platform.select()

Platform-Specific Components

Platform-Specific Code

Android Version Check

Device Type Detection

Platform-Specific File Extensions

Create platform-specific files:
React Native automatically picks the right file:

Platform-Specific Props

React Native Version Check

Mac Catalyst Detection

Testing Mode Detection

Platform-Specific Styles Pattern

Best Practices

Use platform-specific file extensions (.ios.js, .android.js) for components with significantly different implementations instead of cluttering code with conditionals.
The Platform.select() method is preferred over if/else statements for cleaner, more maintainable code.
Don’t over-use platform checks. Try to write cross-platform code whenever possible and only add platform-specific code when necessary.

Common Patterns

Safe Imports

Platform-Aware Constants