Skip to content

lukedj78/dev-flow / rn-expo-router

rn-expo-router

Verified

Use when working with navigation in an Expo + React Native app: adding routes, building tab/stack/drawer layouts, modal routes, dynamic segments (e.g. /profile/[id]), typed routes, deep linking, search params. Triggers on: "add a route", "wire up tabs", "open as modal", "set up deep linking", "configure navigation", or whenever an agent is about to touch a file under app/. Not for: styling navigation chrome (rn-styling), animating transitions (rn-animations-gestures, Wave 3), or non-RN web routing.

references/concepts.md

View on GitHub
> Sources: docs.expo.dev/router, codewithbeto.dev lesson 11 (free).

# Concepts — Expo Router

## File-based routing

The `app/` directory IS the routing config. Every file is a route.

```
app/
├── _layout.tsx              # root layout (wraps everything)
├── index.tsx                # /
├── about.tsx                # /about
├── profile/
│   ├── _layout.tsx          # layout for /profile/*
│   ├── index.tsx            # /profile
│   └── [id].tsx             # /profile/:id (dynamic segment)
└── (tabs)/                  # GROUP — parens are syntax, not URL
    ├── _layout.tsx          # tab navigator
    ├── feed.tsx             # /feed
    └── settings.tsx         # /settings
```

- `_layout.tsx` defines the layout (Stack / Tabs / Drawer / Slot) for its directory.
- `[id].tsx` is a dynamic segment. Access via `useLocalSearchParams<{ id: string }>()`.
- `(name)/` is a route GROUP: parens are stripped from the URL, used for shared layouts and code organization.
- `+not-found.tsx` is the 404 handler.

## Typed routes

With `"typedRoutes": true` in `app.json`, Expo Router generates TypeScript types for every route at build time. Then:

```tsx
import { Href, Link, useRouter } from "expo-router";

const href: Href = { pathname: "/profile/[id]", params: { id: "abc" } };

<Link href={href}>Go</Link>

const router = useRouter();
router.push(href);
```

Wrong route string → compile error. Wrong params → compile error.

## Layouts vs screens

- **Layouts** own the navigator (`<Stack />`, `<Tabs />`, `<Drawer />`) and the chrome (header, tab bar). Defined in `_layout.tsx`.
- **Screens** own only the content. Reference them in the parent layout via `<Stack.Screen name="…" options={…} />`.

```tsx
// app/(tabs)/_layout.tsx
import { Tabs } from "expo-router";

export default function TabsLayout() {
  return (
    <Tabs>
      <Tabs.Screen name="feed" options={{ title: "Feed" }} />
      <Tabs.Screen name="settings" options={{ title: "Settings" }} />
    </Tabs>
  );
}
```

## Groups for auth

```
app/
├── _layout.tsx                  # checks auth, redirects
├── (auth)/                      # public routes
│   ├── _layout.tsx
│   ├── sign-in.tsx
│   └── sign-up.tsx
└── (app)/                       # protected routes
    ├── _layout.tsx              # redirects to /(auth)/sign-in if no user
    ├── index.tsx
    └── profile/[id].tsx
```

## Sources

- https://docs.expo.dev/router/introduction/
- https://docs.expo.dev/router/reference/typed-routes/
- https://docs.expo.dev/router/advanced/router-settings/
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall