feat(mobile): session-gated (app) layout redirects to login when signed out

This commit is contained in:
byGalax
2026-05-13 23:57:43 +02:00
parent 375d28efa5
commit bf02380c19
+9 -4
View File
@@ -1,9 +1,14 @@
// Authenticated app group layout.
// Gate on session: if no session, redirect to `/`.
// Add tab bar / drawer nav here once we have more than one screen.
import { Redirect, Stack } from 'expo-router';
import { Stack } from 'expo-router';
import { useAuth } from '../../lib/authContext';
// Guard for the authenticated route group. While the AuthProvider is
// hydrating from AsyncStorage we render nothing (a brief blank frame)
// rather than flashing the login screen and then snapping into the chat
// list — that's a worse UX than a 200ms blank.
export default function AppLayout() {
const { session, loading } = useAuth();
if (loading) return null;
if (!session) return <Redirect href="/" />;
return <Stack screenOptions={{ headerShown: true }} />;
}