forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiBdcf123aBurak Boduroğlu2 months ago674 commits

guest-guard.tsx16 lines, 482 bytesHistoryRawDownload
1import { Navigate } from "@tanstack/solid-router";
2import { type ParentProps, Show } from "solid-js";
3import { PageSpinner } from "@/components/ui/page-spinner";
4import { useAuth } from "@/stores/auth-context";
5
6export function GuestGuard(props: ParentProps) {
7 const auth = useAuth();
8
9 return (
10 <Show when={!auth.loading()} fallback={<PageSpinner />}>
11 <Show when={!auth.user()} fallback={<Navigate to="/" />}>
12 {props.children}
13 </Show>
14 </Show>
15 );
16}