Back to Rules
TypeScript

Expo React Native TypeScript Best Practices: Cursor Rules for Mobile Development

Claude Directory November 29, 2025
0 copies 2 downloads

Master Expo React Native apps with TypeScript using these rewritten, SEO-optimized best practices. Focus on clean code, performance, security, and accessibility for efficient mobile UI development.

Rule Content
1. **Adopt Functional Programming Patterns**: Craft succinct TypeScript code emphasizing declarative styles and functions over classes to enhance readability and maintainability.

2. **Organize Files Logically**: Arrange code into sections for main exported components, helper subcomponents, utility functions, static data, and type definitions within each file.

3. **Apply Descriptive Naming**: Choose clear variable names incorporating helper verbs like 'isActive' or 'shouldFetch' for intuitive state and action identification.

4. **Use Lowercase-Dashed Directories**: Name folders in lowercase with hyphens, such as 'user-profile', and prioritize named exports for reusable components.

5. **Leverage Interfaces in TypeScript**: Enforce strict typing across all files with interfaces preferred over type aliases; replace enums with object maps for flexibility.

6. **Enable Strict TypeScript Mode**: Activate strict mode to catch errors early and build robust, type-safe functional components.

7. **Format with Prettier and Concise Syntax**: Employ Prettier for uniform styling, 'function' keyword for pure functions, and omit braces in simple conditionals for brevity.

8. **Build Responsive UIs with Flexbox**: Utilize Expo's native components, Flexbox layouts, and useWindowDimensions hook for adaptive designs across devices.

9. **Style with Modern Tools**: Integrate styled-components or Tailwind CSS, support dark mode via useColorScheme, and ensure ARIA-compliant accessibility props.

10. **Animate Smoothly**: Apply react-native-reanimated and react-native-gesture-handler for efficient gesture handling and animations.

11. **Manage Safe Areas Properly**: Implement SafeAreaProvider globally, wrap components in SafeAreaView or SafeAreaScrollView, and avoid manual padding hacks.

12. **Optimize State and Effects**: Limit useState/useEffect; opt for Context, reducers, or Zustand for global state to reduce re-renders.

13. **Enhance Startup and Loading**: Use AppLoading and SplashScreen for seamless app launches, plus expo-image for lazy-loaded, optimized WebP images.

14. **Implement Lazy Loading**: Apply React Suspense, dynamic imports, and memoization with useMemo/useCallback for code splitting and performance.

15. **Navigate Efficiently**: Rely on react-navigation for stacks/tabs/drawers, expo-router for dynamic routes, and deep linking for user flows.

16. **Fetch Data Smartly**: Use react-query for caching/APIs, Context/useReducer for state, and expo-linking for URL params.

17. **Validate with Zod**: Perform runtime checks with Zod, log errors via Sentry or expo-error-reporter, and use early returns for clean error flows.

18. **Test Thoroughly**: Write Jest unit tests with React Native Testing Library, Detox for integrations, and snapshots for UI stability.

19. **Secure Your App**: Sanitize inputs, store secrets in react-native-encrypted-storage, enforce HTTPS, and follow Expo security guidelines.

20. **Support i18n and Permissions**: Enable expo-localization for multi-language/RTL, expo-permissions for devices, expo-constants for configs, and expo-updates for OTA deployments.

Comments

More Rules

View all
AI/ML

GLM-4.7 Optimized Config & System Prompt Designer

Expert system prompt for designing high-performance configurations tailored to GLM-4.7's strengths in coding, reasoning, tool use, and multilingual tasks, backed by benchmarks like SWE-bench and τ²-Bench.

C
Community
AI/ML

GLM-4.7 Open-Source Coding Expert: Optimized System Prompt

Leverage GLM-4.7's top benchmarks in SWE-bench, LiveCodeBench, and more with this system prompt designed for generating clean, secure, open-source-ready code, stunning UIs, and agentic workflows.

C
Community
AI/ML

GLM-4.7 Optimized Coding Agent

This system prompt transforms an AI into GLM-4.7, a benchmark-leading coding agent excelling in agentic workflows, tool use, multilingual coding, and complex reasoning with verified best practices for production-ready open-source development.

C
Community
DevOps

Agentic Dev Loop: Autonomous Jira-Driven Coding Agent with GitHub CI Self-Healing

Ralph, a persistent autonomous AI agent, implements Jira tickets through an endless loop until 100% test success, with GitHub PRs, Jules AI reviews, and CI self-healing for reliable development workflows.

C
Claude Directory
AI/ML

Türk Hukuku Uzmanı AI Agent: Güvenilir Yasal Danışman System Prompt

Claude'u Türk hukuku alanında dünyanın en önde gelen uzmanı olarak yapılandıran, yapılandırılmış yanıtlar, zorunlu uyarılar ve etik sınırlarla donatılmış profesyonel AI agent promptu.

C
Community
Database

PostgreSQL Best Practices: Expert Subagent Guide

Expert subagent providing production-ready PostgreSQL guidance on schema design, query optimization, security, performance tuning, and administration with structured, actionable advice and official references.

C
Claude Directory