Route Guards in Angular — a practical guide to Angular route guards with clear examples you can reuse in real projects.
Angular Tutorial Series (46/119). Prefer one article? Read the complete Angular tutorial.
Short description
Functional guards are the modern style.
Guard tip
export const authGuard: CanActivateFn = () => {
const auth = inject(AuthService);
return auth.isLoggedIn() || inject(Router).createUrlTree(['/login']);
};