@mr.dj2u/knowledge 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/content/checklists/push-merge-loop.md +17 -17
- package/dist/content/checklists/unified-agent-bundle-validation.md +9 -9
- package/dist/content/examples/push-merge-loop.md +14 -14
- package/dist/content/examples/unified-agent-bundle-bootstrap.md +8 -8
- package/dist/content/guides/post-create-onboarding.md +150 -140
- package/dist/content/patterns/api/api-routes.md +313 -313
- package/dist/content/patterns/api/error-handling.md +310 -310
- package/dist/content/patterns/database/drizzle-schema.md +279 -279
- package/dist/content/patterns/database/migrations.md +364 -364
- package/dist/content/patterns/database/query-organization.md +536 -536
- package/dist/content/patterns/database/relations.md +449 -449
- package/dist/content/patterns/deployment/build-configuration.md +440 -440
- package/dist/content/patterns/deployment/ci-cd-patterns.md +447 -447
- package/dist/content/patterns/deployment/environment-config.md +379 -379
- package/dist/content/patterns/deployment/hosting-setup.md +424 -424
- package/dist/content/patterns/project/configuration-patterns.md +459 -459
- package/dist/content/patterns/project/documentation-org.md +506 -506
- package/dist/content/patterns/project/folder-structure.md +397 -397
- package/dist/content/patterns/project/library-exports.md +464 -464
- package/dist/content/patterns/project/monorepo-structure.md +500 -500
- package/dist/content/patterns/routing/dynamic-routes.md +220 -220
- package/dist/content/patterns/routing/file-based-routing.md +185 -185
- package/dist/content/patterns/routing/route-groups.md +428 -428
- package/dist/content/patterns/state/persistence-middleware.md +520 -520
- package/dist/content/patterns/state/selector-hooks.md +537 -537
- package/dist/content/patterns/state/store-organization.md +538 -538
- package/dist/content/patterns/state/zustand-patterns.md +347 -347
- package/dist/content/patterns/styling/component-styling.md +467 -467
- package/dist/content/patterns/styling/responsive-patterns.md +397 -397
- package/dist/content/patterns/styling/theme-configuration.md +425 -425
- package/dist/content/patterns/styling/uniwind-setup.md +411 -411
- package/dist/content/prompts/continue-development.md +41 -35
- package/dist/content/prompts/create-expo-super-stack.md +4 -1
- package/dist/content/prompts/fix-seo.md +29 -29
- package/dist/content/prompts/onboard-new-expo-app.md +11 -11
- package/dist/content/prompts/prepare-deploy.md +29 -29
- package/dist/content/prompts/project-research-plan.md +29 -29
- package/dist/content/prompts/push-merge-loop.md +25 -25
- package/dist/content/prompts/retrospective-project-onboarding.md +23 -0
- package/dist/content/prompts/review-expo-project.md +29 -29
- package/dist/content/prompts/run-doctor.md +38 -38
- package/dist/content/prompts/wrap-up.md +70 -67
- package/dist/content/reference/create-expo-stack-uniwind.md +29 -29
- package/dist/content/reference/doctor-dogfood.md +1 -1
- package/dist/content/reference/mcp-sdk-transport.md +30 -30
- package/dist/content/reference/reference-repo-evacuation.md +31 -31
- package/dist/content/resource-index.json +1 -0
- package/dist/content/rules/env-hygiene.md +10 -0
- package/dist/content/rules/ssr-safety.md +7 -0
- package/dist/content/skills/api-routes.md +34 -33
- package/dist/content/skills/continue-development.md +49 -32
- package/dist/content/skills/debugging.md +32 -32
- package/dist/content/skills/deployment.md +32 -32
- package/dist/content/skills/dev-server-management.md +32 -32
- package/dist/content/skills/env-vars.md +32 -32
- package/dist/content/skills/expo-router-architecture.md +34 -33
- package/dist/content/skills/expo-ssr-safety.md +32 -32
- package/dist/content/skills/plugin-creation.md +41 -41
- package/dist/content/skills/production-server-patterns.md +31 -31
- package/dist/content/skills/project-onboarding.md +35 -31
- package/dist/content/skills/research-plan-intake.md +32 -32
- package/dist/content/skills/seo-metadata.md +31 -31
- package/dist/content/skills/super-stack-startup.md +38 -34
- package/dist/content/skills/uniwind-theming.md +32 -32
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +11 -0
- package/dist/prompts/index.js.map +1 -1
- package/package.json +7 -1
|
@@ -1,186 +1,186 @@
|
|
|
1
|
-
# File-Based Routing with Expo Router
|
|
2
|
-
|
|
3
|
-
## Description
|
|
4
|
-
|
|
5
|
-
File-based routing in Expo Router automatically generates routes from the file structure under the `app/` directory. This pattern eliminates manual route configuration and makes navigation structure immediately visible from the filesystem. Routes are only defined under `app/` — components are NOT split into separate `src/screens/` folders, preventing the duplication problem.
|
|
6
|
-
|
|
7
|
-
## When to Use
|
|
8
|
-
|
|
9
|
-
**Always use** file-based routing for all Expo Router applications:
|
|
10
|
-
- ✅ All page-level components live under `app/` directory structure
|
|
11
|
-
- ✅ Route hierarchy directly mirrors file structure
|
|
12
|
-
- ✅ Route organization is enforced by filesystem constraints
|
|
13
|
-
- ✅ Single source of truth for application navigation
|
|
14
|
-
|
|
15
|
-
## Code Example
|
|
16
|
-
|
|
17
|
-
### File Structure Maps to Routes
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
app/
|
|
21
|
-
├── _layout.tsx → Root layout wrapper (providers, fonts, styling)
|
|
22
|
-
├── index.tsx → / (home page)
|
|
23
|
-
├── about.tsx → /about
|
|
24
|
-
├── (drawer)/ → Route group (no URL segment)
|
|
25
|
-
│ ├── _layout.tsx → Drawer navigator wrapper
|
|
26
|
-
│ ├── home.tsx → /home
|
|
27
|
-
│ └── profile.tsx → /profile
|
|
28
|
-
├── (auth)/ → Route group for authentication
|
|
29
|
-
│ ├── sign-in.tsx → /sign-in
|
|
30
|
-
│ └── sign-up.tsx → /sign-up
|
|
31
|
-
├── events/
|
|
32
|
-
│ ├── index.tsx → /events (list)
|
|
33
|
-
│ └── [id].tsx → /events/:id (detail)
|
|
34
|
-
└── guides/
|
|
35
|
-
├── PLZA/
|
|
36
|
-
│ ├── index.tsx → /guides/PLZA
|
|
37
|
-
│ └── strategies/
|
|
38
|
-
│ └── [id].tsx → /guides/PLZA/strategies/:id
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
**From:** PokePages, not-hot-dog, DJsPortfolio (reference Expo app src/app folders)
|
|
42
|
-
|
|
43
|
-
### Root Layout Setup
|
|
44
|
-
|
|
45
|
-
```typescript
|
|
46
|
-
// app/_layout.tsx
|
|
47
|
-
import { Stack } from 'expo-router';
|
|
48
|
-
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
49
|
-
import { Provider } from 'zustand';
|
|
50
|
-
import { useAuthStore } from '@/store/authStore';
|
|
51
|
-
|
|
52
|
-
export default function RootLayout() {
|
|
53
|
-
const { isLoading } = useAuthStore();
|
|
54
|
-
|
|
55
|
-
if (isLoading) {
|
|
56
|
-
return <LoadingScreen />;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<GestureHandlerRootView style={{ flex: 1 }}>
|
|
61
|
-
<Stack screenOptions={{ headerShown: false }}>
|
|
62
|
-
<Stack.Screen name="(drawer)" />
|
|
63
|
-
<Stack.Screen name="(auth)" />
|
|
64
|
-
</Stack>
|
|
65
|
-
</GestureHandlerRootView>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
**Pattern from:** core-monorepo/apps/*/src/app/_layout.tsx, PokePages/src/app/_layout.tsx
|
|
71
|
-
|
|
72
|
-
## Configuration
|
|
73
|
-
|
|
74
|
-
### Setup in `app.json`
|
|
75
|
-
|
|
76
|
-
```json
|
|
77
|
-
{
|
|
78
|
-
"expo": {
|
|
79
|
-
"plugins": [
|
|
80
|
-
[
|
|
81
|
-
"expo-router",
|
|
82
|
-
{
|
|
83
|
-
"origin": false,
|
|
84
|
-
"asyncRoutes": "development",
|
|
85
|
-
"apiRoutes": true
|
|
86
|
-
}
|
|
87
|
-
]
|
|
88
|
-
],
|
|
89
|
-
"experiments": {
|
|
90
|
-
"typedRoutes": true
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### TypeScript Configuration
|
|
97
|
-
|
|
98
|
-
Enable typed routes in `tsconfig.json`:
|
|
99
|
-
|
|
100
|
-
```json
|
|
101
|
-
{
|
|
102
|
-
"compilerOptions": {
|
|
103
|
-
"paths": {
|
|
104
|
-
"@/*": ["./src/*"]
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
"references": [{ "path": "./tsconfig.app.json" }]
|
|
108
|
-
}
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
## Best Practices
|
|
112
|
-
|
|
113
|
-
### ✅ DO
|
|
114
|
-
|
|
115
|
-
1. **Keep `app/` files lean** — only routing and layout logic
|
|
116
|
-
```typescript
|
|
117
|
-
// app/events/[id].tsx ✅ GOOD
|
|
118
|
-
import { EventDetail } from '@/components/EventDetail';
|
|
119
|
-
import { useLocalSearchParams } from 'expo-router';
|
|
120
|
-
|
|
121
|
-
export default function EventDetailRoute() {
|
|
122
|
-
const { id } = useLocalSearchParams<{ id: string }>();
|
|
123
|
-
return <EventDetail eventId={id} />;
|
|
124
|
-
}
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
2. **Use route groups** for organizational structure without affecting URLs
|
|
128
|
-
```
|
|
129
|
-
(drawer)/ ← drawer navigation group, no URL
|
|
130
|
-
├── (tabs)/ ← tabs group nested in drawer, no URL
|
|
131
|
-
│ ├── home.tsx → /home
|
|
132
|
-
│ └── profile.tsx → /profile
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
3. **Import components from `src/components/`** or `src/screens/`
|
|
136
|
-
```typescript
|
|
137
|
-
import { ProfileScreen } from '@/components/ProfileScreen';
|
|
138
|
-
// NOT: import { ProfileScreen } from './ProfileScreen';
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
4. **Use platform-specific files** for route variations
|
|
142
|
-
```
|
|
143
|
-
[id].tsx ← default (all platforms)
|
|
144
|
-
[id].web.tsx ← web-specific
|
|
145
|
-
[id].native.tsx ← iOS/Android specific
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
### ❌ DON'T
|
|
149
|
-
|
|
150
|
-
1. **Don't put complex logic in route files**
|
|
151
|
-
```typescript
|
|
152
|
-
// ❌ BAD
|
|
153
|
-
export default function EventRoute() {
|
|
154
|
-
const [events, setEvents] = useState([]);
|
|
155
|
-
const [loading, setLoading] = useState(false);
|
|
156
|
-
// ... 50+ lines of business logic
|
|
157
|
-
return <View>...</View>;
|
|
158
|
-
}
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
2. **Don't duplicate screens in `src/screens/`** AND reference from `app/`
|
|
162
|
-
```
|
|
163
|
-
❌ app/events.tsx AND src/screens/EventsScreen.tsx
|
|
164
|
-
✅ app/events.tsx imports from @/components/EventsScreen
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
3. **Don't use `require()` for dynamic routing** — let Expo Router handle it
|
|
168
|
-
```typescript
|
|
169
|
-
// ❌ BAD
|
|
170
|
-
const Screen = require(`./screens/${routeName}`);
|
|
171
|
-
|
|
172
|
-
// ✅ GOOD
|
|
173
|
-
router.push(`/events/${eventId}`);
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
## Related Patterns
|
|
177
|
-
|
|
178
|
-
- [Dynamic Routes](./dynamic-routes.md) — Using `[param].tsx` syntax
|
|
179
|
-
- [Route Groups](./route-groups.md) — Organizing routes with `(group)/` syntax
|
|
180
|
-
- [Navigation Patterns](./navigation-patterns.md) — router.push, Link components, deep linking
|
|
181
|
-
- [API Routes](./api-routes.md) — `+api.ts` catch-all pattern for server endpoints
|
|
182
|
-
|
|
183
|
-
---
|
|
184
|
-
|
|
185
|
-
*Pattern extracted from production repositories: PokePages, not-hot-dog, DJsPortfolio, core-monorepo*
|
|
1
|
+
# File-Based Routing with Expo Router
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
File-based routing in Expo Router automatically generates routes from the file structure under the `app/` directory. This pattern eliminates manual route configuration and makes navigation structure immediately visible from the filesystem. Routes are only defined under `app/` — components are NOT split into separate `src/screens/` folders, preventing the duplication problem.
|
|
6
|
+
|
|
7
|
+
## When to Use
|
|
8
|
+
|
|
9
|
+
**Always use** file-based routing for all Expo Router applications:
|
|
10
|
+
- ✅ All page-level components live under `app/` directory structure
|
|
11
|
+
- ✅ Route hierarchy directly mirrors file structure
|
|
12
|
+
- ✅ Route organization is enforced by filesystem constraints
|
|
13
|
+
- ✅ Single source of truth for application navigation
|
|
14
|
+
|
|
15
|
+
## Code Example
|
|
16
|
+
|
|
17
|
+
### File Structure Maps to Routes
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
app/
|
|
21
|
+
├── _layout.tsx → Root layout wrapper (providers, fonts, styling)
|
|
22
|
+
├── index.tsx → / (home page)
|
|
23
|
+
├── about.tsx → /about
|
|
24
|
+
├── (drawer)/ → Route group (no URL segment)
|
|
25
|
+
│ ├── _layout.tsx → Drawer navigator wrapper
|
|
26
|
+
│ ├── home.tsx → /home
|
|
27
|
+
│ └── profile.tsx → /profile
|
|
28
|
+
├── (auth)/ → Route group for authentication
|
|
29
|
+
│ ├── sign-in.tsx → /sign-in
|
|
30
|
+
│ └── sign-up.tsx → /sign-up
|
|
31
|
+
├── events/
|
|
32
|
+
│ ├── index.tsx → /events (list)
|
|
33
|
+
│ └── [id].tsx → /events/:id (detail)
|
|
34
|
+
└── guides/
|
|
35
|
+
├── PLZA/
|
|
36
|
+
│ ├── index.tsx → /guides/PLZA
|
|
37
|
+
│ └── strategies/
|
|
38
|
+
│ └── [id].tsx → /guides/PLZA/strategies/:id
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**From:** PokePages, not-hot-dog, DJsPortfolio (reference Expo app src/app folders)
|
|
42
|
+
|
|
43
|
+
### Root Layout Setup
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
// app/_layout.tsx
|
|
47
|
+
import { Stack } from 'expo-router';
|
|
48
|
+
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
49
|
+
import { Provider } from 'zustand';
|
|
50
|
+
import { useAuthStore } from '@/store/authStore';
|
|
51
|
+
|
|
52
|
+
export default function RootLayout() {
|
|
53
|
+
const { isLoading } = useAuthStore();
|
|
54
|
+
|
|
55
|
+
if (isLoading) {
|
|
56
|
+
return <LoadingScreen />;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<GestureHandlerRootView style={{ flex: 1 }}>
|
|
61
|
+
<Stack screenOptions={{ headerShown: false }}>
|
|
62
|
+
<Stack.Screen name="(drawer)" />
|
|
63
|
+
<Stack.Screen name="(auth)" />
|
|
64
|
+
</Stack>
|
|
65
|
+
</GestureHandlerRootView>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Pattern from:** core-monorepo/apps/*/src/app/_layout.tsx, PokePages/src/app/_layout.tsx
|
|
71
|
+
|
|
72
|
+
## Configuration
|
|
73
|
+
|
|
74
|
+
### Setup in `app.json`
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"expo": {
|
|
79
|
+
"plugins": [
|
|
80
|
+
[
|
|
81
|
+
"expo-router",
|
|
82
|
+
{
|
|
83
|
+
"origin": false,
|
|
84
|
+
"asyncRoutes": "development",
|
|
85
|
+
"apiRoutes": true
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
],
|
|
89
|
+
"experiments": {
|
|
90
|
+
"typedRoutes": true
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### TypeScript Configuration
|
|
97
|
+
|
|
98
|
+
Enable typed routes in `tsconfig.json`:
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"compilerOptions": {
|
|
103
|
+
"paths": {
|
|
104
|
+
"@/*": ["./src/*"]
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"references": [{ "path": "./tsconfig.app.json" }]
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Best Practices
|
|
112
|
+
|
|
113
|
+
### ✅ DO
|
|
114
|
+
|
|
115
|
+
1. **Keep `app/` files lean** — only routing and layout logic
|
|
116
|
+
```typescript
|
|
117
|
+
// app/events/[id].tsx ✅ GOOD
|
|
118
|
+
import { EventDetail } from '@/components/EventDetail';
|
|
119
|
+
import { useLocalSearchParams } from 'expo-router';
|
|
120
|
+
|
|
121
|
+
export default function EventDetailRoute() {
|
|
122
|
+
const { id } = useLocalSearchParams<{ id: string }>();
|
|
123
|
+
return <EventDetail eventId={id} />;
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
2. **Use route groups** for organizational structure without affecting URLs
|
|
128
|
+
```
|
|
129
|
+
(drawer)/ ← drawer navigation group, no URL
|
|
130
|
+
├── (tabs)/ ← tabs group nested in drawer, no URL
|
|
131
|
+
│ ├── home.tsx → /home
|
|
132
|
+
│ └── profile.tsx → /profile
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
3. **Import components from `src/components/`** or `src/screens/`
|
|
136
|
+
```typescript
|
|
137
|
+
import { ProfileScreen } from '@/components/ProfileScreen';
|
|
138
|
+
// NOT: import { ProfileScreen } from './ProfileScreen';
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
4. **Use platform-specific files** for route variations
|
|
142
|
+
```
|
|
143
|
+
[id].tsx ← default (all platforms)
|
|
144
|
+
[id].web.tsx ← web-specific
|
|
145
|
+
[id].native.tsx ← iOS/Android specific
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### ❌ DON'T
|
|
149
|
+
|
|
150
|
+
1. **Don't put complex logic in route files**
|
|
151
|
+
```typescript
|
|
152
|
+
// ❌ BAD
|
|
153
|
+
export default function EventRoute() {
|
|
154
|
+
const [events, setEvents] = useState([]);
|
|
155
|
+
const [loading, setLoading] = useState(false);
|
|
156
|
+
// ... 50+ lines of business logic
|
|
157
|
+
return <View>...</View>;
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
2. **Don't duplicate screens in `src/screens/`** AND reference from `app/`
|
|
162
|
+
```
|
|
163
|
+
❌ app/events.tsx AND src/screens/EventsScreen.tsx
|
|
164
|
+
✅ app/events.tsx imports from @/components/EventsScreen
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
3. **Don't use `require()` for dynamic routing** — let Expo Router handle it
|
|
168
|
+
```typescript
|
|
169
|
+
// ❌ BAD
|
|
170
|
+
const Screen = require(`./screens/${routeName}`);
|
|
171
|
+
|
|
172
|
+
// ✅ GOOD
|
|
173
|
+
router.push(`/events/${eventId}`);
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Related Patterns
|
|
177
|
+
|
|
178
|
+
- [Dynamic Routes](./dynamic-routes.md) — Using `[param].tsx` syntax
|
|
179
|
+
- [Route Groups](./route-groups.md) — Organizing routes with `(group)/` syntax
|
|
180
|
+
- [Navigation Patterns](./navigation-patterns.md) — router.push, Link components, deep linking
|
|
181
|
+
- [API Routes](./api-routes.md) — `+api.ts` catch-all pattern for server endpoints
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
*Pattern extracted from production repositories: PokePages, not-hot-dog, DJsPortfolio, core-monorepo*
|
|
186
186
|
*File structure observed in: reference Expo app src/app folders
|