You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Mobile/app/(auth)/_layout.tsx

26 lines
749 B

import { Redirect, Stack } from "expo-router";
import { useSession } from "@/ctx";
import { Text } from "@/components/ui/text";
export default function AppLayout() {
const { session, isLoading } = useSession();
// You can keep the splash screen open, or render a loading screen like we do here.
if (isLoading) {
return <Text>Loading...</Text>;
}
// Only require authentication within the (app) group's layout as users
// need to be able to access the (auth) group and sign in again.
if (!session) {
return <Redirect href="/login" />;
}
return (
<Stack>
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
<Stack.Screen name="modal" options={{ presentation: "modal" }} />
</Stack>
);
}