
Product
Introducing Rust Support in Socket
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.
@angular/router
Advanced tools
Supply Chain Security
Vulnerability
Quality
Maintenance
License
The @angular/router package provides navigation and URL manipulation capabilities for Angular applications. It allows developers to define routes, navigate between them, handle route parameters, and guard routes among other functionalities.
Route Configuration
Defines routes in an Angular application, associating paths with components.
const routes: Routes = [
{ path: 'home', component: HomeComponent },
{ path: 'about', component: AboutComponent }
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
Router Outlet
A placeholder that Angular dynamically fills based on the current router state.
<router-outlet></router-outlet>
Navigation
Programmatically navigate to different routes within an Angular application.
constructor(private router: Router) { }
navigateToHome() {
this.router.navigate(['/home']);
}
Route Parameters
Access parameters for a given route, often used for fetching data based on the URL.
constructor(private route: ActivatedRoute) { }
ngOnInit() {
this.route.paramMap.subscribe(params => {
this.userId = params.get('id');
});
}
Route Guards
Protect routes with guards that can allow or prevent navigation to a route based on logic such as authentication.
@Injectable({ providedIn: 'root' })
export class AuthGuard implements CanActivate {
canActivate(
next: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
return this.authService.isAuthenticated();
}
}
React Router is a routing library for React, similar to @angular/router but for React applications. It provides components for navigation, route matching, and history handling. While @angular/router is designed specifically for Angular, React Router is tailored to React's component structure.
Vue Router is the official router for Vue.js. It integrates deeply with Vue.js core to make building Single Page Applications with Vue.js a breeze. It offers features similar to @angular/router but is designed to work seamlessly with Vue.js components and reactivity system.
Reach Router is a small, simple router for React that is accessible and easy to use. It is similar to @angular/router in providing navigation and route matching, but it focuses on simplicity and accessibility. It has now been succeeded by React Router, which has incorporated its accessibility features.
The sources for this package are in the main Angular repo. Please file issues and pull requests against that repo.
Usage information and reference details can be found in Angular documentation.
License: MIT
20.0.1 (2025-06-04)
| Commit | Type | Description | | -- | -- | -- | | 66a0ec6510 | fix | move defer trigger assertions out of parser (#61747) | | 8ecb1ba027 | fix | recover invalid parenthesized expressions (#61815) |
| Commit | Type | Description |
| -- | -- | -- |
| 8c60cbfd1c | fix | takeUntilDestroyed
completes immediately if DestroyRef already destroyed (#61847) |
| b1d960d082 | fix | produce an error when incremental hydration is expected, but not configured (#61741) |
| b4ed62ddf6 | fix | properly handle the case where getSignalGraph is called on a componentless NodeInjector (#60772) |
| ddd22bea48 | fix | unregister onDestroy
in ResourceImpl
when destroy()
is called (#61870) |
| 5c31e7e28d | fix | unregister onDestroy
when observable errors in toSignal
(#61596) |
| Commit | Type | Description | | -- | -- | -- | | e9820a6d48 | fix | avoid trailing whitespaces in unused imports migration (#61698) |
| Commit | Type | Description | | -- | -- | -- | | b93fa22f25 | fix | prevent duplicate fetches during concurrent update checks (#61443) | | 9743bd1317 | fix | update service worker to handle seeking better for videos (#60029) |
<!-- CHANGELOG SPLIT MARKER --><a name="20.0.0"></a>
FAQs
Angular - the routing library
The npm package @angular/router receives a total of 1,985,071 weekly downloads. As such, @angular/router popularity was classified as popular.
We found that @angular/router demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.