liveBook · Manning

Route guard

A route guard is logic that permits, redirects, or blocks navigation or route activation based on application conditions.

How 2 Manning books explain it

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.

Read how Pro Angular 16 explains route guard →

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.

Read how Modern Angular explains route guard →

Related concepts

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.