What is the Platform API in React Native?

Why Interviewers Ask This

Foundational questions like this help interviewers calibrate the rest of the interview. A confident, accurate answer signals that you have solid React Native basics — a prerequisite for any developer role.

Answer

The Platform module allows you to write platform-specific code and detect which platform the app is running on. Platform.OS: returns "ios", "android", "windows", "macos", or "web": import { Platform } from "react-native"; if (Platform.OS === "ios") { // iOS specific code } const statusBarHeight = Platform.OS === "ios" ? 44 : 24;. Platform.select(): cleaner way to select platform-specific values: const styles = StyleSheet.create({ container: { paddingTop: Platform.select({ ios: 44, android: 0, default: 0, }), }, }); const shadow = Platform.select({ ios: { shadowColor: "#000", shadowOffset: { width: 0, height: 2 }, shadowOpacity: 0.25, }, android: { elevation: 4, }, });. Platform.Version: OS version — string on iOS ("17.0"), number on Android (33 = Android 13). Platform-specific files: the cleanest approach for large platform-specific differences. Create two files: Button.ios.tsx and Button.android.tsx. React Native automatically picks the correct file when you import ./Button. Also works with .native.tsx (native vs web) and .web.tsx. isTV / isTVOS: detect TV platforms. isPad (iOS only): detect iPad. Best practice: minimize platform-specific code — the more shared code, the less maintenance. Use platform files for fundamentally different UX, not minor style differences.

Pro Tip

Before answering, structure your response: one-line definition → real-world analogy → concrete example from a project. This makes even complex React Native answers easy to follow.