跳到正文
cccskills
Expo 官方免费在 GitHub 公开

expo-router

Build navigation in Expo Router apps, from file-based screen routes to native tabs, modals, and search bars. Includes organizing route files, sharing screens across tabs, and adding link previews and long-press menus.

中文简介正在准备中。当前显示英语简介。

原文查看原文说明

Navigation and routing for Expo Router. Covers file-based routes, groups and dynamic routes, folder organization, Link with previews and context menus, native Stack, page titles, modals and form sheets, NativeTabs, headers and toolbars, and header search bars.

实测评分 未实测

查看安装方法

适用场景

  • Organizing screen routes and folders
  • Sharing detail screens across tabs
  • Adding modals and form sheets
  • Adding link previews and header search

包含的文件(8)

  • SKILL.md6.9 KB
  • agents/openai.yaml422 B
  • references/form-sheet.md6.2 KB
  • references/route-structure.md5.0 KB
  • references/search.md5.1 KB
  • references/tabs.md13.0 KB
  • references/toolbar-and-headers.md7.9 KB
  • references/zoom-transitions.md4.7 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Expo Router Navigation

Navigation and routing for Expo Router apps. For screen styling, colors, controls, media, and visual effects, use the expo-native-ui skill; for motion and gestures, use expo-animation.

References

Consult these resources as needed:

references/
  route-structure.md     Route conventions, dynamic routes, groups, folder organization
  tabs.md                NativeTabs, migration from JS tabs, iOS 26 features
  toolbar-and-headers.md Stack headers and toolbar buttons, menus, search (iOS only)
  form-sheet.md          Form sheets in expo-router: configuration, footers and background interaction.
  search.md              Search bar with headers, useSearch hook, filtering patterns
  zoom-transitions.md    Apple Zoom: fluid zoom transitions with Link.AppleZoom (iOS 18+)

Code Style

  • Always use kebab-case for file names, e.g. comment-card.tsx
  • Always remove old route files when moving or restructuring navigation
  • Never use special characters in file names
  • Configure tsconfig.json with path aliases, and prefer aliases over relative imports for refactors.

Routes

See ./references/route-structure.md for detailed route conventions.

  • Routes belong in the app directory.
  • Never co-locate components, types, or utilities in the app directory. This is an anti-pattern.
  • Ensure the app always has a route that matches "/", it may be inside a group route.

Library Preferences

  • Color from expo-router for native semantic colors, not raw PlatformColor (type-safe, auto-adapts to light/dark). See expo-native-ui for the full color palette pattern.
  • In SDK 56+, never import from @react-navigation/* directly — use expo-router/react-navigation instead (covers @react-navigation/native, /core, /elements, /routers)

Behavior

  • Prefer Stack.SearchBar to add a search bar to a screen

Navigation

Link

Use <Link href="/path" /> from 'expo-router' for navigation between routes.

import { Link } from 'expo-router';

// Basic link
<Link href="/path" />

// Wrapping custom components
<Link href="/path" asChild>
  <Pressable>...</Pressable>
</Link>

Whenever possible, include a <Link.Preview> to follow iOS conventions. Add context menus and previews frequently to enhance navigation.

Stack

  • ALWAYS use _layout.tsx files to define stacks
  • Use Stack from 'expo-router/stack' for native navigation stacks

Page Title

Set the page title with Stack.Title:

<Stack.Title>Home</Stack.Title>

Context Menus

Add long press context menus to Link components:

import { Link } from "expo-router";

<Link href="/settings" asChild>
  <Link.Trigger>
    <Pressable>
      <Card />
    </Pressable>
  </Link.Trigger>
  <Link.Menu>
    <Link.MenuAction
      title="Share"
      icon="square.and.arrow.up"
      onPress={handleSharePress}
    />
    <Link.MenuAction
      title="Block"
      icon="nosign"
      destructive
      onPress={handleBlockPress}
    />
    <Link.Menu title="More" icon="ellipsis">
      <Link.MenuAction title="Copy" icon="doc.on.doc" onPress={() => {}} />
      <Link.MenuAction
        title="Delete"
        icon="trash"
        destructive
        onPress={() => {}}
      />
    </Link.Menu>
  </Link.Menu>
</Link>;

Link Previews

Use link previews frequently to enhance navigation:

<Link href="/settings">
  <Link.Trigger>
    <Pressable>
      <Card />
    </Pressable>
  </Link.Trigger>
  <Link.Preview />
</Link>

Link preview can be used with context menus.

Modal

Present a screen as a modal:

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

Prefer this to building a custom modal component.

Sheet

Present a screen as a dynamic form sheet:

<Stack.Screen
  name="sheet"
  options={{
    presentation: "formSheet",
    sheetGrabberVisible: true,
    sheetAllowedDetents: [0.5, 1.0],
    contentStyle: { backgroundColor: "transparent" },
  }}
/>
  • Using contentStyle: { backgroundColor: "transparent" } makes the background liquid glass on iOS 26+.

Common route structure

A standard app layout with tabs and stacks inside each tab:

app/
  _layout.tsx — <NativeTabs />
  (index,search)/
    _layout.tsx — <Stack />
    index.tsx — Main list
    search.tsx — Search view
// app/_layout.tsx
import { NativeTabs } from "expo-router/unstable-native-tabs";
import { ThemeProvider, DarkTheme, DefaultTheme } from "expo-router/react-navigation";
import { useColorScheme } from "react-native";

export default function Layout() {
  const colorScheme = useColorScheme();
  return (
    <ThemeProvider value={colorScheme === "dark" ? DarkTheme : DefaultTheme}>
      <NativeTabs>
        <NativeTabs.Trigger name="(index)">
          <NativeTabs.Trigger.Icon sf="list.dash" md="list" />
          <NativeTabs.Trigger.Label>Items</NativeTabs.Trigger.Label>
        </NativeTabs.Trigger>
        <NativeTabs.Trigger name="(search)" role="search" />
      </NativeTabs>
    </ThemeProvider>
  );
}

Create a shared group route so both tabs can push common screens:

// app/(index,search)/_layout.tsx
import { Stack } from "expo-router/stack";
import { colors } from "@/theme/colors";

export default function Layout({ segment }) {
  const screen = segment.match(/\((.*)\)/)?.[1]!;
  const titles: Record<string, string> = { index: "Items", search: "Search" };

  return (
    <Stack
      screenOptions={{
        headerTransparent: true,
        headerShadowVisible: false,
        headerLargeTitleShadowVisible: false,
        headerLargeStyle: { backgroundColor: "transparent" },
        headerTitleStyle: { color: colors.label },
        headerLargeTitleEnabled: true,
        headerBlurEffect: "none",
        headerBackButtonDisplayMode: "minimal",
      }}
    >
      <Stack.Screen name={screen} options={{ title: titles[screen] }} />
      <Stack.Screen name="i/[id]" options={{ headerLargeTitleEnabled: false }} />
    </Stack>
  );
}

headerLargeTitleEnabled is the SDK 56+ option name; older SDKs use headerLargeTitle, which is deprecated upstream.

Submitting Feedback

If you encounter errors, misleading or outdated information in this skill, report it so Expo can improve:

npx --yes @expo/agent-cli@latest feedback --category skills --subject "expo-router" "<actionable feedback>"

Only submit when you have something specific and actionable to report. Include as much relevant context as possible. If an agent repeatedly fails at an Expo task or the user has to step in, submit a brief report of the task, expected result, and what went wrong using --category evals and the relevant Expo package or command as --subject.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

eas-app-stores

Expo 官方免费

Build and submit iOS and Android apps through EAS, an app delivery service. Covers signing, version numbers, store listing information, automated release workflows, and checking submission progress for Expo, React Native, and existing native apps.

中文简介正在准备中。当前显示英语简介。

  • Distributing an iOS beta through TestFlight
  • Preparing an App Store or Google Play submission
  • Configuring signing and build version numbers
expo/skills30002026年10月24日 更新

eas-hosting

Expo 官方免费

Create server endpoints and deploy Expo web apps to EAS Hosting. Covers production and preview deployments, secret environment variables, custom domains, and adapting server code to Cloudflare Workers, the runtime that executes hosted API routes.

中文简介正在准备中。当前显示英语简介。

  • Publishing an Expo web app
  • Creating preview URLs for pull requests
  • Building API proxies that keep keys on the server
expo/skills30002026年10月24日 更新

eas-observe

Expo 官方免费

Add EAS Observe to an Expo app to track startup and navigation performance, custom events, errors, and crashes. Query collected data through the EAS CLI and interpret measurements to investigate slow startup and other performance problems.

中文简介正在准备中。当前显示英语简介。

  • Add performance monitoring to a production Expo app
  • Investigate slow startup and navigation
  • Review JavaScript errors and native crashes
expo/skills30002026年10月24日 更新

eas-simulator

Expo 官方免费

Run an app on a remote iOS or Android simulator hosted by EAS. Control screens, capture screenshots and video, or connect a development build for live updates when a suitable local simulator is unavailable.

中文简介正在准备中。当前显示英语简介。

  • Checking an iOS app from Linux or a cloud environment
  • Having an agent navigate screens and capture screenshots
  • Checking animations and transitions with screen recordings
expo/skills30002026年10月24日 更新

eas-update

Expo 官方免费

Configure EAS Update to deliver compatible JavaScript, styling, and assets to installed apps without a new native build. Guides publishing to selected channels, testing release behavior, and investigating updates that fail to appear.

中文简介正在准备中。当前显示英语简介。

  • Set up remote updates for an Expo app
  • Publish JavaScript fixes to preview or staging
  • Investigate updates missing from TestFlight or production builds
expo/skills30002026年10月24日 更新

eas-update-insights

Expo 官方免费

Assess published EAS Update health using aggregate metrics for crashes, adoption, and payload size. Compare platforms and channels, inspect daily trends, and check how many users run the bundled version versus an over-the-air update.

中文简介正在准备中。当前显示英语简介。

  • Checking update health after publication
  • Comparing crash rates with previous releases
  • Comparing bundled and over-the-air update adoption
expo/skills30002026年10月24日 更新

查看 expo 的全部技能

报告此技能的问题