expo-router Skill: Writing Expo Router Navigation Conventions into the Agent Context

Preface

When modifying navigation in Expo apps, common issues include agents still relying on web-style patterns—hard-wiring imports from react-navigation, mixing components into the app directory, or missing how to configure native Stack, Modal, and NativeTabs. Official documentation is scattered across routing structure, Tabs, Header, Form Sheet, and more, making it hard to align everything in one conversation.

expo-router is a Framework-class Skill (MIT, current material version 1.0.1) provided by the Expo team in expo/skills. It specifically constrains how Agents handle file-based routing, link navigation, native stacks, and common presentation patterns in Expo Router scenarios. It sits alongside expo-overview and expo-project-structure in the official skills ecosystem; UI styling and animations are covered by skills like expo-native-ui and expo-animation.

What this is

expo-router is a SKILL.md guide aimed at AI Agents: when a task involves navigation and routing with Expo Router, the Agent follows these rules to choose APIs, organize the app directory, and consult bundled references/ docs (routing conventions, NativeTabs, Toolbar/Header, Form Sheet, search bar, Apple Zoom transitions, etc.).

Expo documentation, the Expo CLI, and the EAS CLI remain the source of truth; the Skill’s role is to reduce Agents’ misuse of outdated patterns or direct imports across libraries.

Core features

Capabilities explicitly covered include:

  • File routing and directories: Routes live in the app directory; dynamic routes, groups, and folder organization; ensure a route exists that matches / (it can be inside a group); do not co-locate components, types, or utilities under app.
  • Link navigation: expo-router’s <Link href="..." />, with asChild support; encourage use with <Link.Preview> and long-press context menus (Link.Trigger, Link.Menu, Link.MenuAction).
  • Native Stack: Defined via _layout.tsx; import Stack from expo-router/stack; use <Stack.Title> for page titles.
  • Modal and Form Sheet: Stack.Screen with presentation: "modal" or formSheet, including sheetGrabberVisible, sheetAllowedDetents, etc.; for iOS 26+, transparent backgrounds can be relevant to liquid glass effects (as noted in the material).
  • NativeTabs: Use from expo-router/unstable-native-tabs; the material provides typical app/ structure examples with shared group routes and per-tab Stacks.
  • Header and search: Prefer Stack.SearchBar; details in references/search.md, toolbar-and-headers.md.
  • Library and style conventions: File names in kebab-case; delete old route files when moving or refactoring navigation; configure tsconfig.json path aliases and prefer aliases over relative paths; use semantic colors via expo-router’s Color; with SDK 56+, do not import directly from @react-navigation/*—use expo-router/react-navigation.

The Skill also lists reference file paths to open on demand (all under references/), such as route-structure.md, tabs.md, form-sheet.md, zoom-transitions.md (Link.AppleZoom, iOS 18+).

Installation and activation

For Agents like Cursor, Expo Skills recommends the Skills CLI (Claude Code / Codex can use the official Plugin; this article focuses on the CLI, consistent with Cursor scenarios).

Install all Expo Skills (including expo-router) at the project root:

npx skills@latest add expo/skills --skill '*'

The CLI will ask for installation targets; to specify an Agent, add --agent <agent>. Restart or refresh the Agent session after installation so it discovers SKILL.md.

To update only this Skill:

npx skills@latest update expo-router

For broader Expo tasks, have the Agent load expo-overview first, then proceed to expo-router.

Typical usage

The snippets below come from the Skill body and illustrate the code shapes the Agent is guided to produce.

Basic linking:

import { Link } from 'expo-router';

<Link href="/path" />

<Link href="/path" asChild>
  <Pressable>...</Pressable>
</Link>

Modal presentation:

<Stack.Screen name="modal" options={{ presentation: "modal" }} />

Form Sheet:

<Stack.Screen
  name="sheet"
  options={{
    presentation: "formSheet",
    sheetGrabberVisible: true,
    sheetAllowedDetents: [0.5, 1.0],
    contentStyle: { backgroundColor: "transparent" },
  }}
/>

Root layout with NativeTabs + Stacks inside a group (structural sketch):

app/
  _layout.tsx — <NativeTabs />
  (index,search)/
    _layout.tsx — <Stack />
    index.tsx
    search.tsx

The root _layout.tsx uses NativeTabs and ThemeProvider (from expo-router/react-navigation); the shared group’s _layout.tsx uses segment to distinguish the current tab screen and configures Stack.Screen separately for dynamic routes like i/[id]. The material notes that SDK 56+ uses headerLargeTitleEnabled; the older headerLargeTitle has been deprecated upstream.

When to use and cautions

Suitable for: React Native / Expo projects using Expo Router; when you want the Agent to set up Tab + Stack, Modal/Sheet, Link with Preview, header search, and other native navigation patterns; when upgrading or adding features that involve SDK 56 navigation APIs.

Notes:

  • The app directory contains only routes; business components should live in project-defined directories (often consistent with expo-project-structure).
  • NativeTabs path is expo-router/unstable-native-tabs; the API may evolve with the SDK; see references/tabs.md for tabs and iOS 26-related notes.
  • For screen visuals, color systems, and animations, switch to the corresponding skills; avoid inventing styling solutions outside this Skill.
  • If you find errors or outdated content in the Skill, you can submit actionable feedback to Expo:
npx --yes submit-expo-feedback@latest --category skills --subject "expo-router" "<actionable feedback>"

If repeated failures occur or structured evaluation is needed, the material suggests loading the expo-skill-feedback Skill rather than just repeating the command above.

Conclusion

expo-router codifies Expo Router’s file-based routing, Link, native Stack, Modal/Sheet, NativeTabs, and header search into Agent-executable conventions, directly addressing “routing” in Expo’s official mobile development Agent ecosystem. See the complete Skill and reference docs at: https://github.com/expo/skills/tree/main/plugins/expo/skills/expo-router; for the full skills installation and instructions, see https://github.com/expo/skills.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye