Expo Router Patterns

VerifiedSafe

Patterns for Expo Router including Stack configuration, native tabs, and file-based routing best practices for mobile navigation.

Sby Skills Guide Bot
DevelopmentIntermediate
3/11/2026
Claude CodeCursorWindsurfCodex
#expo-router#mobile-navigation#file-based-routing#react-native#expo

Recommended for

Automated summary

This skill documents Expo Router patterns for configuring Stack navigation, native tabs, and file-based routing in an Expo/React Native app.

Strengths

  • Shows minimal Stack setup through screenOptions in the root layout instead of listing every screen
  • Explains per-screen configuration with <Stack.Screen> and dynamic headers via useNavigation and setOptions
  • Covers native tabs with expo-router/unstable-native-tabs, including iOS SF Symbols
  • Explicitly flags common mistakes such as redundant screen listings, misused screenOptions, and overly nested navigators

Limitations

  • Native tabs rely on a module marked unstable, so its API may change
  • Does not address deep linking, authentication flows, or screen transitions and animations
  • Assumes prior familiarity with React Native and the Expo ecosystem
When to use it

Use it when building or changing navigation in an Expo Router app, especially Stack layouts, tabs, or header options.

When not to use it

Avoid it for routing questions outside Expo (plain React Navigation, Next.js) or for non-navigation concerns such as state management or data fetching.

Security analysis

Safe
Quality score82/100

The skill is documentation-only guidance for Expo Router patterns and does not instruct destructive commands, secret exfiltration, network calls, obfuscated payloads, or safety bypasses. Its declared tools are limited to reading and editing local files.

No concerns found

How this analysis is made

Examples

Root Stack layout
Set up the root _layout.tsx in my Expo Router app so the Stack hides headers by default, without listing every screen.
Dynamic header button
Add a header-right add button to app/lesson/[id].tsx using useNavigation and setOptions, and show a 'Lesson' title with a 'Back' label.
Native tabs
Create a native tab layout in app/(tabs)/_layout.tsx with a Home tab using an SF Symbol icon and an Android drawable.

name: expo-router description: Patterns for Expo Router including Stack configuration, native tabs, and file-based routing best practices. Apply when working with navigation, routing, or screen configuration. allowed-tools: Read, Edit, Write, Grep, Glob

Expo Router Patterns

Stack Navigator Configuration

Root Layout Setup

Use screenOptions on the Stack component to set defaults for all screens. Do NOT explicitly list every screen - routes are auto-discovered from the file structure.

// app/_layout.tsx
import { Stack } from 'expo-router';

export default function RootLayout() {
  return (
    <Stack screenOptions={{ headerShown: false }} />
  );
}

Per-Screen Configuration

Individual screens configure their own options using <Stack.Screen> within the component file:

// app/lesson/[id].tsx
import { Stack } from 'expo-router';

export default function LessonScreen() {
  return (
    <View>
      <Stack.Screen
        options={{
          title: 'Lesson',
          headerShown: true,
          headerBackTitle: 'Back',
        }}
      />
      {/* Screen content */}
    </View>
  );
}

Dynamic Header Configuration

Use useNavigation with setOptions for dynamic header content like buttons:

import { useNavigation } from 'expo-router';
import { useLayoutEffect } from 'react';

export default function Screen() {
  const navigation = useNavigation();

  useLayoutEffect(() => {
    navigation.setOptions({
      headerRight: () => (
        <Pressable onPress={handlePress}>
          <Ionicons name="add" size={28} />
        </Pressable>
      ),
    });
  }, [navigation]);

  return <View>{/* content */}</View>;
}

Native Tabs (expo-router/unstable-native-tabs)

Native tabs provide platform-native tab bar with SF Symbols on iOS:

// app/(tabs)/_layout.tsx
import { Icon, Label, NativeTabs } from 'expo-router/unstable-native-tabs';

export default function TabLayout() {
  return (
    <NativeTabs>
      <NativeTabs.Trigger name="index" options={{ title: 'Home' }}>
        <Icon sf="house.fill" drawable="custom_android_drawable" />
        <Label>Home</Label>
      </NativeTabs.Trigger>
    </NativeTabs>
  );
}

Key Principles

  1. File-based routing: Routes are auto-discovered from the app/ directory structure
  2. Minimal configuration: Only configure what you need to override
  3. Screen-level options: Screens configure their own headers/options using <Stack.Screen> within the component
  4. Layout files: _layout.tsx files define navigation structure for their directory
  5. Route groups: Parentheses like (tabs) create route groups without affecting the URL path

Common Mistakes to Avoid

  • Don't list every screen explicitly in Stack - they're auto-discovered
  • Don't use screenOptions for route-specific settings - use <Stack.Screen> in the route file
  • Don't nest navigators deeply - use file-based routing for cleaner structure

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/expo-router-patterns-mmlj2o38/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/expo-router-patterns-mmlj2o38' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/expo-router-patterns-mmlj2o38/download' --output '.skill-downloads/expo-router-patterns-mmlj2o38/SKILL.md.part' && mv '.skill-downloads/expo-router-patterns-mmlj2o38/SKILL.md.part' '.skill-downloads/expo-router-patterns-mmlj2o38/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Tools declared by the author (check availability in your agent): Read, Edit, Write, Grep, Glob

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/expo-router-patterns-mmlj2o38/SKILL.md' && test -s '.skill-downloads/expo-router-patterns-mmlj2o38/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/expo-router' && cp -R '.skill-downloads/expo-router-patterns-mmlj2o38' '.claude/skills/expo-router'

Cursor
test -f '.skill-downloads/expo-router-patterns-mmlj2o38/SKILL.md' && test -s '.skill-downloads/expo-router-patterns-mmlj2o38/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/expo-router' && cp -R '.skill-downloads/expo-router-patterns-mmlj2o38' '.cursor/skills/expo-router'

Codex
test -f '.skill-downloads/expo-router-patterns-mmlj2o38/SKILL.md' && test -s '.skill-downloads/expo-router-patterns-mmlj2o38/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/expo-router' && cp -R '.skill-downloads/expo-router-patterns-mmlj2o38' '.agents/skills/expo-router'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/expo-router-patterns-mmlj2o38'

openskills read 'expo-router-patterns-mmlj2o38'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/expo-router-patterns-mmlj2o38/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills