React Native
What This Does
Provides expert guidance for building React Native applications — from project setup and navigation to native module integration and performance optimization. Covers both Expo-managed and bare workflows, with patterns for state management, styling, and platform-specific code.
Instructions
Assess the project. Determine:
- New project or existing? If existing, Expo or bare workflow?
- Target platforms: iOS only, Android only, or both?
- React Native version and Expo SDK version
- State management: React Context, Zustand, Redux Toolkit, or Jotai?
- Navigation: React Navigation, Expo Router, or other?
Project setup. For new projects:
# Expo (recommended for most projects)
npx create-expo-app@latest my-app --template tabs
# Bare React Native (when you need full native control)
npx @react-native-community/cli init MyApp
Follow React Native patterns:
- Navigation: Use Expo Router (file-based) or React Navigation v7
- State management: Zustand for simplicity, Redux Toolkit for complex state
- Styling: StyleSheet.create for performance, NativeWind for Tailwind syntax
- Data fetching: TanStack Query (React Query) for server state
- Forms: React Hook Form with Zod validation
- Storage: expo-secure-store for secrets, MMKV for general key-value
Navigation architecture:
// Expo Router (file-based routing)
// app/(tabs)/index.tsx -> Tab 1
// app/(tabs)/profile.tsx -> Tab 2
// app/[id].tsx -> Dynamic route
// app/_layout.tsx -> Root layout with navigation container
// React Navigation v7
// Stack, Tab, and Drawer navigators
// Type-safe navigation with TypeScript
Platform-specific code:
// Platform.select for simple differences
const styles = StyleSheet.create({
container: {
padding: Platform.select({ ios: 20, android: 16 }),
},
});
// .ios.tsx / .android.tsx for larger differences
// Button.ios.tsx and Button.android.tsx
Performance optimization:
- Use FlatList/FlashList for long lists (never ScrollView for dynamic lists)
- Memoize expensive computations with useMemo
- Use React.memo for pure components in lists
- Enable Hermes engine (default in modern RN)
- Profile with React DevTools and Flipper
- Avoid inline styles and anonymous functions in render
Native modules. When you need native functionality:
- Check Expo modules first (expo-camera, expo-location, etc.)
- Use Expo Modules API for custom native code in Expo
- Use TurboModules for bare React Native
- Bridge only what you need — minimize native surface area
Output Format
When generating React Native code:
- TypeScript strict mode
- Functional components only
- ESM imports
- StyleSheet.create at the bottom of the file
- Platform-specific code clearly marked
- Include necessary imports for all React Native components used
Tips
- Start with Expo unless you have a specific reason not to — it handles 90% of use cases
- Use Expo EAS Build for CI/CD instead of managing Xcode/Gradle yourself
- FlashList from Shopify is significantly faster than FlatList for large lists
- Test on real devices early — simulators hide performance issues
- Use expo-dev-client for a custom development build with native modules
- Keep native dependencies minimal — each one is a maintenance burden
- Use react-native-reanimated for performant animations on the UI thread
1---2name: react-native3description: React Native development patterns — navigation, native modules, Expo, state management, and cross-platform best practices.4---56# React Native78## What This Does910Provides expert guidance for building React Native applications — from project setup and navigation to native module integration and performance optimization. Covers both Expo-managed and bare workflows, with patterns for state management, styling, and platform-specific code.1112## Instructions13141. **Assess the project.** Determine:15 - New project or existing? If existing, Expo or bare workflow?16 - Target platforms: iOS only, Android only, or both?17 - React Native version and Expo SDK version18 - State management: React Context, Zustand, Redux Toolkit, or Jotai?19 - Navigation: React Navigation, Expo Router, or other?20212. **Project setup.** For new projects:22 ```bash23 # Expo (recommended for most projects)24 npx create-expo-app@latest my-app --template tabs2526 # Bare React Native (when you need full native control)27 npx @react-native-community/cli init MyApp28 ```29303. **Follow React Native patterns:**31 - **Navigation:** Use Expo Router (file-based) or React Navigation v732 - **State management:** Zustand for simplicity, Redux Toolkit for complex state33 - **Styling:** StyleSheet.create for performance, NativeWind for Tailwind syntax34 - **Data fetching:** TanStack Query (React Query) for server state35 - **Forms:** React Hook Form with Zod validation36 - **Storage:** expo-secure-store for secrets, MMKV for general key-value37384. **Navigation architecture:**39 ```typescript40 // Expo Router (file-based routing)41 // app/(tabs)/index.tsx -> Tab 142 // app/(tabs)/profile.tsx -> Tab 243 // app/[id].tsx -> Dynamic route44 // app/_layout.tsx -> Root layout with navigation container4546 // React Navigation v747 // Stack, Tab, and Drawer navigators48 // Type-safe navigation with TypeScript49 ```50515. **Platform-specific code:**52 ```typescript53 // Platform.select for simple differences54 const styles = StyleSheet.create({55 container: {56 padding: Platform.select({ ios: 20, android: 16 }),57 },58 });5960 // .ios.tsx / .android.tsx for larger differences61 // Button.ios.tsx and Button.android.tsx62 ```63646. **Performance optimization:**65 - Use FlatList/FlashList for long lists (never ScrollView for dynamic lists)66 - Memoize expensive computations with useMemo67 - Use React.memo for pure components in lists68 - Enable Hermes engine (default in modern RN)69 - Profile with React DevTools and Flipper70 - Avoid inline styles and anonymous functions in render71727. **Native modules.** When you need native functionality:73 - Check Expo modules first (expo-camera, expo-location, etc.)74 - Use Expo Modules API for custom native code in Expo75 - Use TurboModules for bare React Native76 - Bridge only what you need — minimize native surface area7778## Output Format7980When generating React Native code:81- TypeScript strict mode82- Functional components only83- ESM imports84- StyleSheet.create at the bottom of the file85- Platform-specific code clearly marked86- Include necessary imports for all React Native components used8788## Tips8990- Start with Expo unless you have a specific reason not to — it handles 90% of use cases91- Use Expo EAS Build for CI/CD instead of managing Xcode/Gradle yourself92- FlashList from Shopify is significantly faster than FlatList for large lists93- Test on real devices early — simulators hide performance issues94- Use expo-dev-client for a custom development build with native modules95- Keep native dependencies minimal — each one is a maintenance burden96- Use react-native-reanimated for performant animations on the UI thread