Agent Skills: React Native Platform-Specific Code

Handle iOS and Android differences using Platform API and native modules in React Native. Use when handling platform-specific behavior or integrating native modules in React Native. (triggers: **/*.tsx, **/*.ts, **/*.ios.*, **/*.android.*, Platform, Platform.select, native-module, ios, android)

UncategorizedID: hoangnguyen0403/agent-skills-standard/react-native-platform-specific

Install this agent skill to your local

pnpm dlx add-skill https://github.com/HoangNguyen0403/agent-skills-standard/tree/HEAD/skills/react-native/react-native-platform-specific

Skill Files

Browse the full folder contents for react-native-platform-specific.

Download Skill

Loading file tree…

skills/react-native/react-native-platform-specific/SKILL.md

Skill Metadata

Name
react-native-platform-specific
Description
"Handle iOS and Android differences using Platform API and native modules in React Native. Use when handling platform-specific behavior or integrating native modules in React Native. (triggers: **/*.tsx, **/*.ts, **/*.ios.*, **/*.android.*, Platform, Platform.select, native-module, ios, android)"

React Native Platform-Specific Code

Priority: P1 (OPERATIONAL)

Split Platform-Specific Files

Use .ios. and .android. for platform-specific files:

See native modules reference for platform-specific file naming, Platform.select usage, and native bridge examples.

React Native automatically picks the right file:

  • iOS: Button.ios.tsx then Button.tsx (fallback)
  • Android: Button.android.tsx then Button.tsx (fallback)

Apply Platform Branching Inline

Use Platform.select or Platform.OS for small differences within a shared file.

Integrate Native Modules

  • Expo: Use Expo modules when available (expo-* packages).
  • Bare RN: Use community modules (@react-native-community/*).
  • Custom: Write native modules in Swift/Kotlin when needed.

Anti-Patterns

  • No Excessive Branching: Extract to separate files if logic diverges significantly.
  • No Hardcoded Version Checks: Use feature detection.
  • No Ignoring Android: Test on both platforms.

References

See references/native-modules.md for Platform detection examples, Native Bridge (iOS/Android), Expo JSI Modules, and SafeArea handling.