What Is New in Angular 18.0
Angular 18.0 delivers a significant update focused on developer experience, performance, and modern web standards. This release introduces zoneless change detection, deferred views, and enhanced server-side rendering capabilities.
| Category | Key Updates |
|---|---|
| New Features | Zoneless Change Detection, Deferred Views, RedirectCommand for SSR |
| Developer Experience | Improved Debugging, Enhanced Hydration Logs, Schematics Updates |
| Performance | Faster Builds, Optimized CLI Commands, i18n Hydration Support |
| Deprecations | Router class and factory functions, TestBed legacy APIs |
How does zoneless change detection work?
Angular 18 introduces experimental support for zoneless change detection, a paradigm shift from the traditional Zone.js-based approach. This allows developers to opt-out of Zone.js and manage change detection through signals, markForCheck, or explicit calls to ApplicationRef.tick.
In practice, this means applications can have smaller bundle sizes and more predictable performance. You can enable it by configuring the bootstrap process with provideExperimentalZonelessChangeDetection().
bootstrapApplication(AppComponent, {
providers: [provideExperimentalZonelessChangeDetection()]
});
What are the new deferred view features?
Deferred views, built on the JavaScript IntersectionObserver API, now support more flexible triggers for lazy-loading content. Beyond the existing on viewport and on idle triggers, you can now use custom conditions.
New triggers include on interaction, on hover, on immediate, and on timer. This granular control lets you optimize initial load times by deferring non-critical components until specific user actions occur.
<div>
<button #trigger>Load</button>
@defer (on interaction(trigger)) {
<heavy-component />
}
</div>
How is server-side rendering improved?
Server-side rendering gets a major boost with the new RedirectCommand for redirecting users directly from the server. This is more efficient than the client-side redirects used previously.
The update also enhances debugging with more detailed hydration logs. These logs help identify DOM mismatches between the server and client, which is crucial for diagnosing and fixing SSR issues quickly.
What developer tools have been upgraded?
The Angular CLI and Angular DevTools received significant updates. The CLI now uses a persistent build cache by default, which dramatically improves build and test execution speeds for subsequent runs.
Angular DevTools introduces better support for exploring the component tree and debugging applications, especially those using the new zoneless change detection mode. This makes the development feedback loop much faster.
FAQ
Is Zone.js being removed in Angular 18?
No, Zone.js is not removed. Angular 18 introduces an experimental, opt-in API for zoneless change detection. Zone.js remains the default and fully supported method for change detection. The zoneless option is for developers who want to explore a different paradigm for potential performance benefits.
How do I try out the new deferred view triggers?
You can use the new triggers like on interaction or on hover by updating your templates. Import the DeferrableViews symbol and use the new syntax within an @defer block. The Angular compiler will handle the rest, generating the necessary code based on the Intersection Observer API.
What is the benefit of RedirectCommand for SSR?RedirectCommand allows a server-side rendered application to perform a redirect before the client-side bundle is downloaded or executed. This improves performance and user experience by avoiding a full client-side page reload for common redirect scenarios, like authentication guards.
Are there any breaking changes in Angular 18?
While there are deprecations, there are few breaking changes. The most notable deprecations are for the Router class and factory functions, and legacy TestBed APIs. The framework warns you to use newer APIs, but existing code will continue to work for now.
How do I enable the persistent build cache in the CLI?
The persistent build cache is now enabled by default in new v18 projects. For existing projects, you can enable it by updating your angular.json file. Set the cli.cache.enabled property to true to benefit from faster rebuilds.