t1k:rn:base:architecture
| Field | Value |
|---|---|
| Module | base |
| Version | 1.7.4 |
| Effort | medium |
| Tools | — |
Keywords: architecture, expo router, file-based routing, project structure, react native, typescript
How to invoke
Section titled “How to invoke”/t1k:rn:base:architectureRN Base Architecture
Section titled “RN Base Architecture”Project Structure (Expo Router)
Section titled “Project Structure (Expo Router)”app/├── (tabs)/ # Tab group — shared tab bar│ ├── _layout.tsx # Tab navigator config│ ├── index.tsx # Home tab│ └── profile.tsx # Profile tab├── _layout.tsx # Root layout — providers, fonts, splash├── +not-found.tsx # 404 screencomponents/ # Shared UI componentshooks/ # Custom hooksstore/ # Zustand storesservices/ # API calls, external servicesconstants/ # Colors, sizes, configassets/ # Images, fontsRoot Layout Pattern
Section titled “Root Layout Pattern”import { Stack } from 'expo-router';import { useColorScheme } from '@/hooks/useColorScheme';
export default function RootLayout() { return ( <Stack> <Stack.Screen name="(tabs)" options={{ headerShown: false }} /> <Stack.Screen name="+not-found" /> </Stack> );}TypeScript Config
Section titled “TypeScript Config”{ "extends": "expo/tsconfig.base", "compilerOptions": { "strict": true, "baseUrl": ".", "paths": { "@/*": ["./*"] } }}Key Rules
Section titled “Key Rules”- Always use
strict: truein tsconfig - Path alias
@/for absolute imports — never use../../.. - Group routes with
(groupName)/— does not affect URL - Private routes with
_prefix — excluded from routing - Layouts in
_layout.tsx— required at each route group level - Use
expo-constantsfor env vars — never hardcode API URLs
Gotchas
Section titled “Gotchas”expo-routerrequiresexpo-linkingandreact-native-safe-area-contextapp/+html.tsxonly runs on web — do not rely on for mobile- Dynamic segments:
app/user/[id].tsx→useLocalSearchParams<{ id: string }>() - Always wrap root layout in
<ThemeProvider>before<Stack>
Security
Section titled “Security”- Store secrets in
.env— never commit to git - Use
expo-secure-storefor sensitive user data (tokens, keys) - Validate all route params before use — treat as untrusted input