Route guard
A route guard is logic that permits, redirects, or blocks navigation or route activation based on application conditions.
Pro Angular 16
A route guard is an Angular service or class that controls whether navigation to a route or loading of a route module may proceed.
- How it is used
- Controls navigation when routes require application state, authentication, user consent, or protection against abandoned edits.
- How deep it goes
- Works through guard registration, route configuration, synchronous and asynchronous results, child routes, deactivation, and dynamic loading.
- Examples
- Uses direct cart URL reloads, protected administration, terms confirmation, unsaved product edits, and first-time dynamic-module loading.
- What you can do after
- Build it from scratch by registering guard services, attaching them to routes, and returning decisions or awaiting user responses.
Modern Angular
An Angular routing guard is a router hook that controls whether navigation or route activation may proceed.
- How it is used
- Restricts enterprise route access according to authentication status and other user categories.
- How deep it goes
- Explains class-based and functional implementations, dependency injection, observable decisions, redirects, and route registration.
- Examples
- Uses an HRMS AuthGuard that redirects unauthenticated users to /login and protects a lazy-loaded employees route.
- What you can do after
- Build it from scratch as a class-based or functional authentication guard and attach it to an Angular route.
Related concepts
- server-side renderingcontrasts with · A web-rendering technique in which a server generates a user interface’s markup or other rendered representation before delivering it to a client.
- routingused by · Routing is the selection of a path, destination, or processing component to direct an item, request, or flow toward an intended endpoint.
- servicekind of · A service is a software or computing capability that provides defined functionality to users or other components through an interaction boundary.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

