From bf02380c1964bccfc221b1110aa4caf425924bb7 Mon Sep 17 00:00:00 2001 From: byGalax Date: Wed, 13 May 2026 23:57:43 +0200 Subject: [PATCH] feat(mobile): session-gated (app) layout redirects to login when signed out --- apps/mobile/app/(app)/_layout.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/mobile/app/(app)/_layout.tsx b/apps/mobile/app/(app)/_layout.tsx index e6b0685..fedb0bd 100644 --- a/apps/mobile/app/(app)/_layout.tsx +++ b/apps/mobile/app/(app)/_layout.tsx @@ -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 ; return ; }