platform-detection

Installation
SKILL.md

Platform Detection

Core Principles

Use PlatformIs utility for readable platform checks. The PlatformIs.ios() and PlatformIs.android() functions are more readable than Platform.OS === 'ios' and provide consistent API across the codebase with type safety.

Use Platform.OS for direct comparisons. When PlatformIs is unavailable, use Platform.OS === 'ios' or Platform.OS === 'android' with strict equality (===) and lowercase platform strings.

Use Platform.select for platform-specific values. Platform.select provides type-safe selection of values based on platform, avoiding repetitive conditional logic for constants, styles, or configuration.

Use platform-specific file extensions for major differences. Files with .ios.tsx or .android.tsx extensions are automatically loaded by platform, completely separating platform-specific implementations.

Why: Platform detection enables conditional behavior, UI adjustments, and API usage tailored to iOS and Android. Following these patterns ensures readable, maintainable, and testable cross-platform code.

When to Use This Skill

Use these patterns when:

Installs
1
GitHub Stars
3
First Seen
Apr 22, 2026