Files
Volleyball/frontend/src/pages/ProtectedRoute.tsx
2025-05-20 22:58:31 +02:00

9 lines
293 B
TypeScript

import { Navigate } from 'react-router-dom';
import { useAuth } from './AuthContext';
import { JSX } from 'react';
export default function ProtectedRoute({ children }: { children: JSX.Element }) {
const { token } = useAuth();
return token ? children : <Navigate to="/login" replace />;
}