No slash command · from react-native-plugin
Guides navigation setup in React Native: React Navigation v7 (classical) and Expo Router (file-based). Covers stack/tab/drawer navigators, deep linking, typed routes, auth flows, and modal presentation.
Ships in react-native-plugin. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Two paradigms in 2024+:
Detect which the project uses and apply matching patterns.
| Marker (in dependencies) | Library |
|---|---|
@react-navigation/native + at least one navigator (@react-navigation/native-stack, @react-navigation/bottom-tabs, @react-navigation/drawer) | React Navigation v7 |
expo-router | Expo Router |
| Both | Migrating; mirror what's used in the area you touch |
// App.tsx
import 'react-native-gesture-handler'; // first import
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { SafeAreaProvider } from 'react-native-safe-area-context';
const Stack = createNativeStackNavigator<RootStackParamList>();
export default function App() {
return (
<SafeAreaProvider>
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen name="Profile" component={ProfileScreen} options={{ title: 'Profile' }} />
</Stack.Navigator>
</NavigationContainer>
</SafeAreaProvider>
);
}
react-native-gesture-handler MUST be imported first in App.tsx (or index.js) for swipe gestures to work.
@react-navigation/native-stack — uses native iOS UINavigationController and Android Fragment. Faster, native feel. Default choice.@react-navigation/stack — pure JS/Reanimated. Customizable transitions but slower.Prefer Native Stack unless you need custom transitions JS Stack offers.
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { Ionicons } from '@expo/vector-icons';
const Tab = createBottomTabNavigator<MainTabParamList>();
<Tab.Navigator>
<Tab.Screen
name="Home"
component={HomeScreen}
options={{
tabBarIcon: ({ color, size }) => <Ionicons name="home" color={color} size={size} />,
}}
/>
<Tab.Screen name="Profile" component={ProfileStack} />
</Tab.Navigator>
tabBarIcon, tabBarBadge, tabBarLabel — common per-screen options.
import { createDrawerNavigator } from '@react-navigation/drawer';
const Drawer = createDrawerNavigator<DrawerParamList>();
<Drawer.Navigator>
<Drawer.Screen name="Home" component={HomeScreen} />
<Drawer.Screen name="Settings" component={SettingsScreen} />
</Drawer.Navigator>
Common pattern: drawer wraps a stack navigator per top-level item.
// types/navigation.ts
export type RootStackParamList = {
Home: undefined;
Profile: { userId: string };
Settings: { initialTab?: 'general' | 'privacy' };
Modal: { title: string };
};
export type MainTabParamList = {
HomeTab: undefined;
ProfileTab: { userId: string };
};
// Screen props
import type { NativeStackScreenProps } from '@react-navigation/native-stack';
type Props = NativeStackScreenProps<RootStackParamList, 'Profile'>;
export function ProfileScreen({ route, navigation }: Props) {
const { userId } = route.params;
return /* ... */;
}
// useNavigation in nested components
import { useNavigation } from '@react-navigation/native';
import type { NativeStackNavigationProp } from '@react-navigation/native-stack';
const navigation = useNavigation<NativeStackNavigationProp<RootStackParamList>>();
navigation.navigate('Profile', { userId: '123' });
For composite navigators (tab nested in stack):
import type { CompositeScreenProps } from '@react-navigation/native';
type ProfileTabProps = CompositeScreenProps<
BottomTabScreenProps<MainTabParamList, 'ProfileTab'>,
NativeStackScreenProps<RootStackParamList>
>;
Switch top-level navigator based on auth state:
function RootNavigator() {
const { user } = useAuth();
return (
<NavigationContainer>
{user ? <AppStack /> : <AuthStack />}
</NavigationContainer>
);
}
The whole tree unmounts on auth change — clean state. Alternative: keep both stacks mounted and use navigation.reset on logout.
<Stack.Navigator>
<Stack.Group>
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen name="Profile" component={ProfileScreen} />
</Stack.Group>
<Stack.Group screenOptions={{ presentation: 'modal' }}>
<Stack.Screen name="EditProfile" component={EditProfileScreen} />
<Stack.Screen name="Settings" component={SettingsScreen} />
</Stack.Group>
</Stack.Navigator>
presentation: 'modal' — slides up from bottom, dismissible by swipe. iOS native style.
presentation: 'transparentModal' — overlay with transparent background.
Other options: 'card' (default push), 'fullScreenModal', 'formSheet' (iOS-only sheet).
const linking = {
prefixes: ['myapp://', 'https://myapp.example.com'],
config: {
screens: {
Home: '',
Profile: 'profile/:userId',
Settings: 'settings',
Modal: 'modal',
NotFound: '*',
},
},
};
<NavigationContainer linking={linking}>...</NavigationContainer>
URL scheme registration:
app.json "expo": { "scheme": "myapp" }.Info.plist CFBundleURLTypes.AndroidManifest.xml <intent-filter>.For Universal Links (iOS) / App Links (Android), domain verification required (apple-app-site-association JSON, assetlinks.json).
navigation.navigate('Profile', { userId: '123' });
navigation.push('Profile', { userId: '456' }); // always pushes new instance
navigation.replace('Login'); // replaces current
navigation.goBack();
navigation.popToTop();
navigation.reset({ index: 0, routes: [{ name: 'Home' }] });
navigation.setOptions({ title: 'Updated' }); // dynamic header
navigate(name) — goes to existing instance if found, else pushes new.
push(name) — always creates new instance (e.g., infinite drill-down lists).
File-based routing in app/ folder, mirrors Next.js App Router patterns.
// app.json or app.config.js — enable Expo Router
{
"expo": {
"scheme": "myapp",
"plugins": ["expo-router"],
"experiments": { "typedRoutes": true }
}
}
// package.json main entry
{ "main": "expo-router/entry" }
app/
├── _layout.tsx # root layout (always Stack/Tabs/Slot)
├── index.tsx # / (home)
├── +not-found.tsx # 404
├── (auth)/ # group (parens hide from URL)
│ ├── _layout.tsx # auth stack layout
│ ├── login.tsx # /login
│ └── signup.tsx # /signup
├── (app)/
│ ├── _layout.tsx # tabs/drawer layout
│ ├── index.tsx # /
│ ├── profile.tsx # /profile
│ └── [id].tsx # /:id
└── _root.tsx # SafeAreaProvider, providers
// app/_layout.tsx
import { Stack } from 'expo-router';
import { SafeAreaProvider } from 'react-native-safe-area-context';
export default function RootLayout() {
return (
<SafeAreaProvider>
<Stack>
<Stack.Screen name="(app)" options={{ headerShown: false }} />
<Stack.Screen name="(auth)" options={{ headerShown: false }} />
</Stack>
</SafeAreaProvider>
);
}
// app/(app)/_layout.tsx — tabs
import { Tabs } from 'expo-router';
import { Ionicons } from '@expo/vector-icons';
export default function AppLayout() {
return (
<Tabs>
<Tabs.Screen name="index" options={{ title: 'Home', tabBarIcon: ({ color }) => <Ionicons name="home" color={color} /> }} />
<Tabs.Screen name="profile" options={{ title: 'Profile' }} />
</Tabs>
);
}
import { useRouter, useLocalSearchParams, useGlobalSearchParams, Link } from 'expo-router';
// Programmatic
const router = useRouter();
router.push('/profile');
router.push({ pathname: '/[id]', params: { id: '123' } });
router.replace('/login');
router.back();
// Local search params (current route only)
const { id } = useLocalSearchParams<{ id: string }>();
// Global search params (any ancestor)
const { tab } = useGlobalSearchParams<{ tab?: string }>();
// Link
<Link href="/profile">Profile</Link>
<Link href={{ pathname: '/[id]', params: { id: '123' } }}>User</Link>
// app/_layout.tsx
import { Stack, useRouter, useSegments } from 'expo-router';
import { useEffect } from 'react';
import { useAuth } from '@/hooks/useAuth';
export default function RootLayout() {
const { user, loading } = useAuth();
const segments = useSegments();
const router = useRouter();
useEffect(() => {
if (loading) return;
const inAuthGroup = segments[0] === '(auth)';
if (!user && !inAuthGroup) router.replace('/login');
else if (user && inAuthGroup) router.replace('/');
}, [user, segments, loading, router]);
return <Stack screenOptions={{ headerShown: false }} />;
}
Enable in app.json:
{ "expo": { "experiments": { "typedRoutes": true } } }
Generates expo-router/types.ts — Link href, router.push paths are type-checked. Wrong path = compile error.
| Library | Configuration |
|---|---|
| React Navigation | linking prop on NavigationContainer, mapping URL paths to screens |
| Expo Router | URL scheme in app.json; routes inferred from app/ tree automatically |
For testing deep links:
xcrun simctl openurl booted myapp://profile/123.adb shell am start -W -a android.intent.action.VIEW -d "myapp://profile/123".Two common approaches:
Both work; pick what the project uses.
react-native-gesture-handler import at the very top of App.tsx / index.js.<NavigationContainer> at root (React Navigation).useNavigation() calls — pick one approach project-wide.route.params is the source of truth.navigation.navigate('Login') to log out instead of navigation.reset — old screens stay in stack.presentation: 'modal' on screens that should slide up modally.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub aratkruglik/claude-sdlc --plugin react-native-plugin5 skills in this plugin
/rn-conventionsReact Native project structure, Expo vs bare workflow detection, app.json/app.config.js patterns, asset handling, fonts, styling approaches, hot-reload-friendly idioms.
Use this skill to:
- Detect Expo (managed/dev-client/EAS/ejected) vs bare RN workflow.
- Pick correct project layout for each workflow.
- Configure app.json / app.config.js with bundle ID, splash, icons, deep link schemes.
- Handle assets, fonts, images correctly.
- Pick a styling approach (StyleSheet / NativeWind / restyle / styled-components).
Do NOT use this skill for:
- Platform-specific branching (see rn-platform-specific).
- Navigation (see rn-navigation).
- Storage (see rn-state-and-storage).
- Testing (see rn-testing).
/rn-platform-specificiOS / Android platform-specific code in React Native: Platform.OS, Platform.select, .ios.tsx / .android.tsx file extensions, native modules, permissions, safe area handling, status bar.
Use this skill to:
- Branch code at runtime via Platform.OS / Platform.select.
- Use file extensions for whole-component swaps.
- Link and use native modules (Expo SDK or autolinked bare).
- Handle permissions across platforms.
- Configure status bar and safe area correctly.
Do NOT use this skill for:
- General project structure (see rn-conventions).
- Navigation (see rn-navigation).
- Storage (see rn-state-and-storage).
- Testing (see rn-testing).
Other plugins' skills for the same job