Files
cameleer-saas/ui/src/auth/ProtectedRoute.tsx

9 lines
324 B
TypeScript
Raw Normal View History

import { Navigate } from 'react-router';
import { useAuthStore } from './auth-store';
export function ProtectedRoute({ children }: { children: React.ReactNode }) {
const isAuthenticated = useAuthStore((s) => s.isAuthenticated);
if (!isAuthenticated) return <Navigate to="/login" replace />;
return <>{children}</>;
}