Expo Router + NativeWind — App Móvil HADA
Guía completa para desarrollar la app móvil de HADA con Expo SDK, Expo Router
(navegación file-based al estilo Next.js) y NativeWind (clases Tailwind en React Native).
Orientada a usuarios no tecnológicos: UI clara, onboarding rápido, deep links funcionales.
Referencias disponibles
Lee el archivo correspondiente según la tarea:
references/setup-and-config.md — Instalación, estructura de carpetas, babel config, variables de entorno
references/routing-and-navigation.md — Expo Router: layouts, Stack, Tabs, rutas dinámicas, deep links
references/nativewind-patterns.md — NativeWind: configuración, clases frecuentes, componentes base
references/screens.md — Pantallas principales de HADA: onboarding, listas, reservas, círculos
references/push-notifications.md — Expo Notifications: permisos, tokens, manejo foreground/background
Cuándo usar cada referencia
| Tarea |
Referencia |
| Configurar el proyecto móvil por primera vez |
setup-and-config.md |
| Crear rutas, layouts, tabs o navegación entre pantallas |
routing-and-navigation.md |
| Estilizar componentes con clases Tailwind |
nativewind-patterns.md |
| Implementar pantallas de onboarding, listas, reservas |
screens.md |
| Registrar token FCM, manejar notificaciones push, deep links |
push-notifications.md |
Reglas críticas (siempre en contexto)
1. Expo Router: la estructura de carpetas ES la navegación
apps/mobile/app/
├── _layout.tsx ← Root layout: providers, auth gate, SplashScreen
├── (auth)/
│ ├── _layout.tsx ← Stack sin header ni tabs
│ ├── login.tsx
│ └── register.tsx
├── (app)/
│ ├── _layout.tsx ← Tabs: Home, Círculos, Perfil
│ ├── index.tsx ← Tab Home: listas del usuario
│ ├── circles/
│ │ ├── index.tsx ← Lista de círculos
│ │ └── [id].tsx ← Detalle círculo: rutas dinámicas /circles/:id
│ ├── lists/
│ │ ├── [id].tsx ← Lista de deseos con regalos
│ │ └── [id]/
│ │ └── add-gift.tsx ← Añadir regalo a la lista
│ └── profile/
│ └── index.tsx
└── +not-found.tsx
2. NativeWind: usar className en componentes nativos, no style
// ❌ Evitar StyleSheet cuando NativeWind está disponible
const styles = StyleSheet.create({ container: { padding: 16 } });
<View style={styles.container} />
// ✅ NativeWind con className
<View className="p-4 bg-white rounded-2xl shadow-sm" />
3. Deep links apuntan a rutas de Expo Router directamente
hada://lists/uuid-de-la-lista → app/(app)/lists/[id].tsx
hada://profiles/uuid/lists → app/(app)/profile/index.tsx
hada://circles/join?code=XXXX → app/(app)/circles/join.tsx
4. Tokens FCM se registran en el backend DESPUÉS del login exitoso
const token = await registerForPushNotifications();
if (token) await api.post('/notifications/token', { token });
5. La privacidad del reservante se respeta en el frontend
// ❌ Nunca mostrar quién reservó, aunque llegara del backend
<Text>{gift.reservation?.reservadoPor}</Text>
// ✅ Solo mostrar el estado visual
{gift.estado === 'RESERVED' && <Badge>Ya reservado 🔒</Badge>}
Fuentes y documentación oficial
1---2name: expo-router-nativewind3description: Desarrollo de aplicaciones móviles con Expo SDK, Expo Router (navegación file-based) y NativeWind (Tailwind CSS en React Native) para producción. Usar PROACTIVAMENTE cuando se trabaje con pantallas, navegación, layouts, deep links, notificaciones push en Expo, estilos con NativeWind/Tailwind en RN, o cualquier tarea del frontend móvil del proyecto. Activar siempre que aparezcan las palabras clave: Expo, expo-router, NativeWind, Expo Router, Stack, Tabs, app/(tabs), _layout.tsx, useRouter, useLocalSearchParams, usePathname, expo-notifications, deep link, notificaciones push Expo, tailwind en React Native, className en RN, useSafeAreaInsets, SplashScreen, o cualquier pantalla de la app móvil HADA.4---56# Expo Router + NativeWind — App Móvil HADA78Guía completa para desarrollar la app móvil de HADA con Expo SDK, Expo Router9(navegación file-based al estilo Next.js) y NativeWind (clases Tailwind en React Native).10Orientada a usuarios no tecnológicos: UI clara, onboarding rápido, deep links funcionales.1112## Referencias disponibles1314Lee el archivo correspondiente según la tarea:1516- `references/setup-and-config.md` — Instalación, estructura de carpetas, babel config, variables de entorno17- `references/routing-and-navigation.md` — Expo Router: layouts, Stack, Tabs, rutas dinámicas, deep links18- `references/nativewind-patterns.md` — NativeWind: configuración, clases frecuentes, componentes base19- `references/screens.md` — Pantallas principales de HADA: onboarding, listas, reservas, círculos20- `references/push-notifications.md` — Expo Notifications: permisos, tokens, manejo foreground/background2122---2324## Cuándo usar cada referencia2526| Tarea | Referencia |27| ------------------------------------------------------------ | --------------------------- |28| Configurar el proyecto móvil por primera vez | `setup-and-config.md` |29| Crear rutas, layouts, tabs o navegación entre pantallas | `routing-and-navigation.md` |30| Estilizar componentes con clases Tailwind | `nativewind-patterns.md` |31| Implementar pantallas de onboarding, listas, reservas | `screens.md` |32| Registrar token FCM, manejar notificaciones push, deep links | `push-notifications.md` |3334---3536## Reglas críticas (siempre en contexto)3738### 1. Expo Router: la estructura de carpetas ES la navegación3940```41apps/mobile/app/42├── _layout.tsx ← Root layout: providers, auth gate, SplashScreen43├── (auth)/44│ ├── _layout.tsx ← Stack sin header ni tabs45│ ├── login.tsx46│ └── register.tsx47├── (app)/48│ ├── _layout.tsx ← Tabs: Home, Círculos, Perfil49│ ├── index.tsx ← Tab Home: listas del usuario50│ ├── circles/51│ │ ├── index.tsx ← Lista de círculos52│ │ └── [id].tsx ← Detalle círculo: rutas dinámicas /circles/:id53│ ├── lists/54│ │ ├── [id].tsx ← Lista de deseos con regalos55│ │ └── [id]/56│ │ └── add-gift.tsx ← Añadir regalo a la lista57│ └── profile/58│ └── index.tsx59└── +not-found.tsx60```6162### 2. NativeWind: usar `className` en componentes nativos, no `style`6364```tsx65// ❌ Evitar StyleSheet cuando NativeWind está disponible66const styles = StyleSheet.create({ container: { padding: 16 } });67<View style={styles.container} />6869// ✅ NativeWind con className70<View className="p-4 bg-white rounded-2xl shadow-sm" />71```7273### 3. Deep links apuntan a rutas de Expo Router directamente7475```76hada://lists/uuid-de-la-lista → app/(app)/lists/[id].tsx77hada://profiles/uuid/lists → app/(app)/profile/index.tsx78hada://circles/join?code=XXXX → app/(app)/circles/join.tsx79```8081### 4. Tokens FCM se registran en el backend DESPUÉS del login exitoso8283```tsx84const token = await registerForPushNotifications();85if (token) await api.post('/notifications/token', { token });86```8788### 5. La privacidad del reservante se respeta en el frontend8990```tsx91// ❌ Nunca mostrar quién reservó, aunque llegara del backend92<Text>{gift.reservation?.reservadoPor}</Text>9394// ✅ Solo mostrar el estado visual95{gift.estado === 'RESERVED' && <Badge>Ya reservado 🔒</Badge>}96```9798---99100## Fuentes y documentación oficial101102- **Expo Router Docs**: https://docs.expo.dev/router/introduction/103- **Expo Router Deep Linking**: https://docs.expo.dev/router/reference/url-parameters/104- **NativeWind v4 Docs**: https://www.nativewind.dev/105- **NativeWind + Expo Router Setup**: https://www.nativewind.dev/getting-started/expo-router106- **Expo Notifications**: https://docs.expo.dev/versions/latest/sdk/notifications/107- **Expo SDK Reference**: https://docs.expo.dev/versions/latest/108- **EAS Build**: https://docs.expo.dev/build/introduction/109- **Expo Config Plugins**: https://docs.expo.dev/config-plugins/introduction/