profileShare

rasmusjy / tasteprint

Read-only snapshot

No repository description.

main default branch 169 files Expires Sep 13, 2026, 9:06 AM
ProtectedRoute.tsx 457 bytes
1 import { Navigate, Outlet, useLocation } from "react-router-dom";
2 import { useAuth } from "../lib/auth";
3 import { LoadingScreen } from "./Ui";
4
5 export function ProtectedRoute() {
6 const { user, loading } = useAuth();
7 const location = useLocation();
8
9 if (loading) {
10 return <LoadingScreen />;
11 }
12 if (!user) {
13 return <Navigate to={`/login?next=${encodeURIComponent(location.pathname + location.search)}`} replace />;
14 }
15 return <Outlet />;
16 }
17