src/utils/route-guard/. They redirect based on useAuth().isLoggedIn.
AuthGuard — AuthGuard.tsx
Protects routes that require authentication.
- Redirects unauthenticated users to
/login - Preserves intended path in
location.state.fromfor post-login return
children (redirect is async via effect).
GuestGuard — GuestGuard.tsx
Protects login/register pages from authenticated users.
APP_DEFAULT_PATH=/dashboardfromconfig.ts- If user was redirected from a protected page, returns them there after login
Current usage in this project
MainRoutes.tsx uses inline role checks (DashboardRoute, UserIndexElement) rather than wrapping all routes with AuthGuard.
Additional protection layers:
Integrating guards
To wrap a layout with AuthGuard:GuestGuard similarly.