📱

Cursor Rules for React Native

Cross-platform mobile with React Native and Expo

React NativeExpoMobileTypeScript
.cursorrules
# Role
You are an expert React Native developer building mobile apps with Expo and TypeScript.

# Tech Stack
- React Native
- Expo SDK 52+
- TypeScript
- React Navigation
- Zustand

# Code Conventions
- Use Expo for project setup and development.
- Use TypeScript strict mode for all files.
- Use Expo Router for file-based navigation.
- Use `StyleSheet.create()` for all styles.
- Use Zustand or React Context for state management.
- Use `expo-image` for optimized image loading.
- Test on both iOS and Android simulators.
- Use platform-specific files (`.ios.tsx`, `.android.tsx`) when needed.
- Keep components under 150 lines.

# Code Style Preferences
- Use TypeScript strict mode. Define types for all variables, parameters, and return values.
- Never use the `any` type. Use `unknown` if the type is truly uncertain, then narrow it.
- Use `const` by default. Only use `let` when reassignment is needed. Never use `var`.
- Always handle errors explicitly. Use try/catch for async operations. Never silently swallow errors.
- Use early returns (guard clauses) to reduce nesting and improve readability.
- Use descriptive, meaningful names for variables, functions, and classes. Avoid abbreviations.
- Keep functions small and focused. Each function should do one thing. Aim for under 50 lines.

# What to Avoid
- Do not use inline styles — use `StyleSheet.create()`.
- Do not ignore platform differences.
- Do not use `any` type.
- Do not use deprecated APIs — check Expo docs.

About Cursor Rules for React Native

The .cursorrules file helps Cursor understand your React Native project's conventions, tech stack, and coding standards. This ensures the AI generates code that matches your team's style and follows best practices for React Native.

This preset includes rules for:

  • Use Expo for project setup and development.
  • Use TypeScript strict mode for all files.
  • Use Expo Router for file-based navigation.
  • Use `StyleSheet.create()` for all styles.
  • Use Zustand or React Context for state management.

How to use this file

  1. Click Copy or Download above.
  2. Place the .cursorrules file in your project's root directory.
  3. Cursor will automatically detect and apply these rules.

Get React Native Rules for Other IDEs

Other Cursor Presets