All skills
callstackincubator avatar

/react-native-best-practices

@fa0bad0 official

Provides React Native performance optimization guidelines for FPS, TTI, bundle size, memory leaks, re-renders, and animations. Applies to tasks involving Hermes optimization, JS thread blocking, bridge overhead, FlashList, native modules, or debugging jank and frame drops.

Use this Skill: https://skilld.dev/gh/callstackincubator/agent-skills/react-native-best-practices

This session only. Nothing lands on disk.

referencesbundle-analyze-app.md

≈1.4k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Skill: Analyze App Bundle Size

Measure iOS and Android app download/install sizes using Ruler, App Store Connect, and Emerge Tools.

Quick Command

# Android (Ruler)
cd android && ./gradlew analyzeReleaseBundle

# iOS (Xcode export with thinning)
cd ios && xcodebuild -exportArchive \
  -archivePath MyApp.xcarchive \
  -exportPath ./export \
  -exportOptionsPlist ExportOptions.plist
# Check: App Thinning Size Report.txt

When to Use

  • App download size is too large
  • Users complain about storage usage
  • App approaching store limits
  • Comparing releases for size regression

Note: This skill involves visual size reports (Ruler, Emerge Tools X-Ray). When regression checks include device flows, use agent-device for app evidence; install it through the environment's approved/trusted path or ask the user if verification needs it and it is missing. Size report analysis itself may still require exported reports, browser screenshots, or human review. Record concrete module/file names and before/after artifact sizes in text when asking an agent to reason about them.

Key Metrics

Metric Description User Impact
Download Size Compressed, transferred over network Download time, data usage
Install Size Uncompressed, on device storage Storage space

Google finding: Every 6 MB increase reduces installs by 1%.

Android: Ruler (Spotify)

Setup

Add to android/build.gradle:

buildscript {
    dependencies {
        classpath("com.spotify.ruler:ruler-gradle-plugin:2.0.0-beta-3")
    }
}

Add to android/app/build.gradle:

apply plugin: "com.spotify.ruler"

ruler {
    abi.set("arm64-v8a")  // Target architecture
    locale.set("en")
    screenDensity.set(480)
    sdkVersion.set(34)
}

Analyze

cd android
./gradlew analyzeReleaseBundle

Opens HTML report with:

  • Download size
  • Install size
  • Component breakdown (biggest → smallest)

CI Size Validation

ruler {
    verification {
        downloadSizeThreshold = 20 * 1024 * 1024  // 20 MB
        installSizeThreshold = 50 * 1024 * 1024   // 50 MB
    }
}

Build fails if thresholds exceeded.

iOS: Xcode App Thinning

Via App Store Connect (Most Accurate)

After uploading to TestFlight:

  1. Open App Store Connect
  2. Go to your build
  3. View size table by device variant

Note: TestFlight builds include debug data, App Store builds slightly larger due to DRM.

Via Xcode Export

Export an archive with app thinning enabled for all compatible device variants.

Or in ExportOptions.plist:

<key>thinning</key>
<string>&lt;thin-for-all-variants&gt;</string>

Output

Creates folder with:

  • Universal IPA: All variants combined
  • Thinned IPAs: One per device variant
  • App Thinning Size Report.txt:
Variant: SampleApp-<UUID>.ipa
App + On Demand Resources size: 3.5 MB compressed, 10.6 MB uncompressed
App size: 3.5 MB compressed, 10.6 MB uncompressed
  • Compressed = Download size
  • Uncompressed = Install size

Emerge Tools (Cross-Platform)

Third-party service with visual analysis.

Upload

Upload IPA, APK, or AAB through their web interface or CI integration.

Features

Emerge Tools X-Ray for iOS

  • X-Ray: Treemap visualization (like source-map-explorer for binaries)
    • Shows Frameworks (hermes.framework), Mach-O sections (TEXT, DATA), etc.
    • Color-coded: Binaries, Localizations, Fonts, Asset Catalogs, Videos, CoreML Models
    • Visible components: main.jsbundle (JS code), RCT modules, DYLD sections
  • Breakdown: Component-by-component size
  • Insights: Automated suggestions (use with caution)

Caution: Some suggestions may not apply to React Native (e.g., "remove Hermes").

Size Comparison

Tool Platform Accuracy CI Integration
Ruler Android High Yes (Gradle)
App Store Connect iOS Highest No
Xcode Export iOS High Yes (xcodebuild)
Emerge Tools Both High Yes (API)

Typical React Native App Sizes

Component Approximate Size
Hermes engine ~2-3 MB
React Native core ~3-5 MB
JavaScript bundle 1-10 MB
Assets (images, etc.) Varies

Baseline empty app: ~6-10 MB download

Optimization Impact Example

Optimization Size Reduction
Enable R8 (Android) ~30%
Remove unused polyfills 400+ KB
Asset catalog (iOS) 10-50% of assets
Tree shaking 10-15%

Quick Commands

# Android release bundle size
cd android && ./gradlew bundleRelease
# Check: android/app/build/outputs/bundle/release/

# iOS archive
cd ios && xcodebuild -workspace ios/MyApp.xcworkspace \
  -scheme MyApp \
  -configuration Release \
  -archivePath MyApp.xcarchive \
  archive

# Export with thinning report
cd ios && xcodebuild -exportArchive \
  -archivePath MyApp.xcarchive \
  -exportPath ./export \
  -exportOptionsPlist ExportOptions.plist

Related Skills

Source: SKILL.md on GitHub

1 alert17d5 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    This skill provides a comprehensive performance optimization guide for React Native applications. It contains standard developer workflows using command-line tools and patterns for advanced techniques like remote code splitting, which include detailed security hardening advice.

  • Socket17d

    No alerts

  • Snyk17d

    Risk: LOW · No issues

  • Runlayer7mo

    11/31 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at fa0bad0. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated 2 months ago
  • Performance
  • react-native
  • optimization
  • profiling
  • fps
  • bundle-size
  • memory
  • hermes
  • flatlist
  • animations

README badge

README badge for callstackincubator/agent-skills/react-native-best-practices

Provides React Native performance optimization guidelines covering FPS, TTI, bundle size, memory leaks, re-renders, and animations. Includes reference documentation for Hermes, FlashList, Turbo Modules, React Compiler, Reanimated, and profiling with Xcode and Android Studio.

Generated from the current SKILL.md.

Does this skill cover Expo apps?
Yes. The guidelines apply to both bare React Native and Expo projects. Expo SDK 52+ supports tree shaking and Re.Pack code splitting.
What performance metrics should I measure first?
Start with FPS (use React Native DevTools), Time To Interactive (TTI), bundle size, and memory growth. The skill emphasizes measuring baseline metrics before and after optimization to validate improvements.
Does this cover Hermes optimization?
Yes. The skill includes Hermes-specific guidance such as disabling JS bundle compression on Android to enable mmap, and checking Hermes API coverage before removing polyfills.
What if I'm using a list library other than FlatList or FlashList?
The skill prioritizes FlatList and FlashList as virtualized replacements for ScrollView. It includes library version checks (e.g., FlashList v2 API changes) but focuses on these two libraries.
Does this include native profiling guidance?
Yes. The skill covers profiling with Xcode Instruments (iOS) and Android Studio CPU Profiler, plus guidance on native threading, Turbo Modules, and C++ performance-critical code.

Generated from the current SKILL.md. These answers refresh after source changes.