```
## How to protect specific routes
If you would like to check that the user is authenticated only on specific routes, you could implement a method similar to the below example in your code:
br
```typescript
import { FC, useEffect } from 'react';
import { useAuthRoutes, useAuthUserOrNull, useIsAuthenticated } from "@frontegg/react";
import { useLocation, useNavigate } from "react-router-dom";
const ProtectRoute: FC = (props) => {
const user = useAuthUserOrNull();
const navigate = useNavigate();
const location = useLocation();
const { loginUrl } = useAuthRoutes();
const isAuthenticated = useIsAuthenticated();
useEffect(() => {
if(!isAuthenticated) {
navigate([loginUrl, '?redirectUrl=', encodeURIComponent(location.pathname + location.search + location.hash)].join(''))
}
}, [navigate, loginUrl])
if (isAuthenticated && user)
return <>{props.children}>;
return null;
};
export default ProtectRoute;
```
```typescript
function App() {
const [isLoading, setIsLoading] = useState(true);
return (
<>
}/>
}/>
{isLoading && 'This is my custom Loader'}
>
);
}
export default App;
```