Skip to content

Add NativeWind and Expo Router cursorrules under Mobile Development#298

Open
sanketsahu wants to merge 1 commit into
PatrickJS:mainfrom
sanketsahu:add-nativewind-expo-router-rules
Open

Add NativeWind and Expo Router cursorrules under Mobile Development#298
sanketsahu wants to merge 1 commit into
PatrickJS:mainfrom
sanketsahu:add-nativewind-expo-router-rules

Conversation

@sanketsahu
Copy link
Copy Markdown

@sanketsahu sanketsahu commented May 29, 2026

Add NativeWind and Expo Router cursorrules

Adds two related .mdc rules for the React Native / Expo stack. Both filled gaps I hit repeatedly when agents (Cursor and Claude Code) work on Expo apps.

NativeWind (rules/nativewind-cursorrules-prompt-file.mdc)

NativeWind ships Tailwind classes into RN. The repo has many web-Tailwind rules but no dedicated NativeWind rule. Coverage:

  • Setup that's specific to RN (babel, metro withNativeWind, global.css, nativewind-env.d.ts)
  • className vs style discipline and when to use which
  • The strict subset of Tailwind that NativeWind actually translates to RN, and what doesn't (no :hover/:focus-visible, no grid, no animate-*)
  • Dark mode with class strategy + useColorScheme() from nativewind
  • Platform variants (ios:, android:, web:)
  • Performance considerations and common "class doesn't apply" pitfalls

Expo Router (rules/expo-router-cursorrules-prompt-file.mdc)

The existing react-native-expo-router-typescript-windows rule is broad (mixes RN, Expo, Windows setup) and dated (pins NativeWind 2.x). A focused, modern Expo Router rule is additive. Coverage:

  • Directory structure (app/, _layout.tsx, route groups (name), dynamic [id] / catch-all [...slug])
  • Layout primitives (Stack, Tabs, Drawer) and when to use each
  • Search params with useLocalSearchParams, typed routes via experiments.typedRoutes
  • <Link> vs imperative useRouter() — when each is correct
  • Modals and presentation styles, including cross-platform caveats
  • Auth gating patterns — using <Redirect> over useEffect for SSR-safety
  • Web compatibility, SEO via <Stack.Screen options={{ title }} />
  • Common pitfalls: missing default exports, undefined params on first render, flickering tabs during auth checks

Both entries added under ### Mobile Development in alphabetical position.

Format follows the modern Cursor Project Rules spec (description, globs, alwaysApply frontmatter) per CONTRIBUTING.md.

Summary by CodeRabbit

  • Documentation
    • Added Cursor rules for Expo Router covering file-based routing, layouts, dynamic/catch-all routes, navigation/linking, typed routes/search params, auth gating/redirects, web compatibility, modal presentation, and common pitfalls.
    • Added Cursor rules for NativeWind with setup steps, platform-specific styling guidance, dark mode, performance tips, and reference links.
    • Updated Mobile Development list to include Expo Router and reordered related entries.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 29, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2c470fc8-a79e-4c9d-b50a-ac3141caab83

📥 Commits

Reviewing files that changed from the base of the PR and between 63dce1d and 1ce0819.

📒 Files selected for processing (3)
  • README.md
  • rules/expo-router-cursorrules-prompt-file.mdc
  • rules/nativewind-cursorrules-prompt-file.mdc
✅ Files skipped from review due to trivial changes (2)
  • rules/expo-router-cursorrules-prompt-file.mdc
  • rules/nativewind-cursorrules-prompt-file.mdc
🚧 Files skipped from review as they are similar to previous changes (1)
  • README.md

📝 Walkthrough

Walkthrough

Adds two Cursor rules documentation files for Expo Router and NativeWind and updates the README Mobile Development list to include Expo Router; files provide detailed guidance for routing, layouts, styling, platform differences, and common pitfalls.

Changes

Mobile Development Cursor Rules

Layer / File(s) Summary
Expo Router routing framework rules
README.md, rules/expo-router-cursorrules-prompt-file.mdc
README Mobile Development section is updated to add an Expo Router catalog entry; new Expo Router Cursor rules document covers file-based routing, layouts (Stack/Tabs/groups), dynamic/catch-all routes, navigation/linking, typed routes and params, modals, auth gating/redirects, web compatibility, pitfalls, and reference links.
NativeWind styling framework rules
rules/nativewind-cursorrules-prompt-file.mdc
New NativeWind Cursor rules document covers setup (Babel, Metro, global.css, Tailwind config), className vs inline style selection, Tailwind feature parity (web-only utilities noted), dark mode via useColorScheme(), semantic theme tokens, platform-specific variants (ios:/android:/web:), performance/animation guidance, common pitfalls, and documentation links.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • PatrickJS/awesome-cursorrules#141: Updates existing React Native/Expo navigation guidance to switch from React Navigation to Expo Router, complementing the new Expo Router Cursor rules file added in this PR.

Suggested reviewers

  • PatrickJS

Poem

🐰 I hopped through docs with a tiny cheer,

Expo Router maps the paths so clear,
NativeWind stitches styles with care,
Platform-safe tokens flutter in the air,
A little rabbit nods — rules are here.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add NativeWind and Expo Router cursorrules under Mobile Development' directly and clearly describes the main change—adding two new Cursor rules files.
Description check ✅ Passed The description comprehensively covers objectives, value, file changes, and quality criteria alignment. All key sections are present and properly filled with relevant details about the rule content and implementation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@rules/nativewind-cursorrules-prompt-file.mdc`:
- Line 34: The current line conflates opacity and shadow as "web only"; update
the text so that platform scope applies only to shadow semantics/utilities:
create separate bullets or clauses where `opacity-*` is described as supported
on React Native (keep `opacity-*` as platform-appropriate) and qualify
shadow-specific items (e.g., `shadow-inner`, arbitrary `shadow-[...]` and shadow
semantics) as "web only" for NativeWind; reference the terms `opacity-*`,
`shadow`, `shadow-inner`, and `shadow-[...]` when editing so the web-only note
is scoped to shadow only.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 107580c0-9ee5-4773-8500-e9a9ec6b7c02

📥 Commits

Reviewing files that changed from the base of the PR and between 11ae73c and 8624255.

📒 Files selected for processing (3)
  • README.md
  • rules/expo-router-cursorrules-prompt-file.mdc
  • rules/nativewind-cursorrules-prompt-file.mdc

- Sizing: `w-*`, `h-*`, `w-full`, `max-w-md`
- Colors and typography: `bg-*`, `text-*`, `font-bold`, `text-lg`
- Borders and radius: `border`, `border-2`, `rounded-md`, `border-border`
- Opacity, shadow (web only — for native use `shadow-*` with explicit color)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

In current NativeWind docs, are opacity utilities supported on React Native, and which shadow utilities/behaviors differ between native and web?

💡 Result:

In current NativeWind documentation, opacity utilities (e.g., opacity-{n}, opacity-[n]) are supported on React Native [1]. Regarding shadow utilities, there are distinct differences between native and web behaviors due to React Native's underlying styling constraints [2][3][4]: 1. Supported Utilities: Standard shadow utilities such as shadow, shadow-{n}, and shadow-none are supported [2]. 2. Web-Only Utilities: Certain complex shadow utilities, including shadow-inner and arbitrary values (shadow-[n]), are explicitly marked as web-only in the documentation [2]. 3. Native-Specific Behavior: - Shadows on native platforms often require an explicit background color to render correctly [2][3]. - NativeWind maps Tailwind shadow classes to React Native-specific properties, primarily utilizing shadowOffset, shadowColor, and shadowOpacity on iOS, and elevation on Android [5][3][6]. - Users are advised that shadow inconsistencies across platforms can occur [7][6]. While newer React Native versions (0.79+) have introduced a cross-platform boxShadow prop, NativeWind's integration of these features is evolving as the ecosystem transitions toward the new architecture [5][6].

Citations:


Fix misleading “web only” wording on line 34 (scope it to shadow, not opacity).

Line 34 currently reads as if both opacity and shadow are web-only; NativeWind opacity utilities are supported on React Native. Split/reword so “web only” applies to shadow-specific semantics/utilities (e.g., shadow-inner / arbitrary shadow-[...]), while keeping opacity-* platform-appropriate (e.g., its own bullet).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@rules/nativewind-cursorrules-prompt-file.mdc` at line 34, The current line
conflates opacity and shadow as "web only"; update the text so that platform
scope applies only to shadow semantics/utilities: create separate bullets or
clauses where `opacity-*` is described as supported on React Native (keep
`opacity-*` as platform-appropriate) and qualify shadow-specific items (e.g.,
`shadow-inner`, arbitrary `shadow-[...]` and shadow semantics) as "web only" for
NativeWind; reference the terms `opacity-*`, `shadow`, `shadow-inner`, and
`shadow-[...]` when editing so the web-only note is scoped to shadow only.

@PatrickJS PatrickJS force-pushed the add-nativewind-expo-router-rules branch from 8624255 to 63dce1d Compare May 29, 2026 23:33
@PatrickJS PatrickJS force-pushed the add-nativewind-expo-router-rules branch from 63dce1d to 1ce0819 Compare June 1, 2026 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant