DEV Community

With Code Example
With Code Example

Posted on • Originally published at withcodeexample.com

Angular 20 Features and Examples

Angular 20, released in late May 2025, marks a pivotal update in the Angular ecosystem, focusing on reactivity, performance, and developer experience. Below is a detailed breakdown of its most significant features, complete with code examples and practical implications.

Signals API Goes Stable

Angular 20 stabilizes the Signals API, a major leap toward fine-grained reactivity. Signals are reactive primitives similar to React’s useState or Vue’s refs, enabling state updates that only re-render what’s necessary.

Example:

import { signal } from '@angular/core';

const counter = signal(0);

function increment() {
  counter.set(counter() + 1);
}

Enter fullscreen mode Exit fullscreen mode

This makes state management simpler and more predictable, reducing the need for RxJS in many scenarios.

Zoneless Change Detection (Developer Preview)

Angular 20 introduces experimental support for zoneless change detection, allowing developers to opt out of Zone.js. This results in:

  • Smaller bundle sizes (no Zone.js dependency)
  • Faster change detection cycles
  • Cleaner stack traces for easier debugging

How to enable:

import { provideZonelessChangeDetection } from '@angular/core';

bootstrapApplication(AppComponent, {
  providers: [provideZonelessChangeDetection()]
});

Enter fullscreen mode Exit fullscreen mode

Manual change detection can be done via ChangeDetectorRef or by leveraging Signals for automatic UI updates.

Reactive API Improvements: Effect and Resource APIs

  • Effect API: Automatically manages side effects in response to signal changes.
  • Resource API: Simplifies handling of asynchronous operations, tying async data directly to signal-based state.

Example:

import { effect, signal } from '@angular/core';

const userId = signal(1);

effect(() => {
  // Fetch user data whenever userId changes
  fetchUser(userId());
});

Enter fullscreen mode Exit fullscreen mode

This enables more declarative and maintainable code for state and side effects.

Signal-Based Forms (Experimental)

Angular 20 introduces experimental signal-based forms, aiming for unified reactivity and efficient state management in forms.

Features:

  • Real-time validation via computed signals
  • Scalable for complex forms

Example:

import { signal } from '@angular/core';

const name = signal('');
const isValid = computed(() => name().length > 2);

Enter fullscreen mode Exit fullscreen mode

Form controls and validations update reactively, improving UX and code clarity.

Selectorless Components

Angular 20 allows for selectorless components, streamlining imports and reducing boilerplate. This improves ergonomics for standalone and dynamically created components, making refactoring easier.

Incremental Hydration and Flexible Rendering

  • Incremental Hydration: Improves Largest Contentful Paint (LCP) and SEO by only hydrating visible parts of the page.
  • Flexible Rendering Modes: Developers can choose rendering strategies to optimize performance.

Example:

@Component({
  selector: 'my-component',
  template: `
    @defer { ... }
  `
})
export class MyComponent {}

Enter fullscreen mode Exit fullscreen mode

This leverages the @defer directive for faster initial loads and better SEO.

Accessibility Enhancements

Angular 20 introduces accessibility primitives and real-time CLI warnings, making it easier to build inclusive applications and catch issues during development.

Improved Testing Facilities

  • Karma Deprecated: Angular 20 moves away from Karma, introducing experimental support for Web Test Runner and Vitest, both of which are faster and more modern.
  • Example: No code required—just select the new test runner in your Angular CLI setup.

Router Improvements

  • Scroll Options: Native scroll behaviors now supported.
  • Resolvers: Child resolvers can access parent route data.
  • Async Redirects: redirectTo can now return Promises or Observables.
  • Custom Elements: Use custom elements as hosts for RouterLink.

Example:

this.scroller.scrollToPosition([0, 10], { behavior: 'smooth' });

Enter fullscreen mode Exit fullscreen mode
provideRouter([
  { path: 'users/:id', resolve: { user: userResolver }, children: [
    { path: 'posts', resolve: { posts: postsResolver }, component: UserPosts }
  ]}
]);

Enter fullscreen mode Exit fullscreen mode

Two-Way Binding for Dynamically Created Components

Angular 20 now supports two-way data binding for components created at runtime, making dynamic UIs (like modals and form generators) much easier to manage[6].

Smaller Bundles and Faster Load Times

  • Improved tree-shaking aggressively removes dead code.
  • Ivy compiler enhancements reduce memory usage and rebuild times.

Summary Table: Angular 20 Key Features

Feature Description/Benefit Example/Usage
Signals API (Stable) Fine-grained reactivity, replaces some RxJS const count = signal(0);
Zoneless Change Detection No Zone.js, faster, smaller bundles provideZonelessChangeDetection()
Effect/Resource APIs Manage side effects, async state effect(() => {...})
Signal-Based Forms (Experimental) Reactive, scalable forms const name = signal('')
Selectorless Components Less boilerplate, better ergonomics Import directly, no selector
Incremental Hydration Faster LCP, better SEO @defer directive
Accessibility Primitives Easier, real-time accessibility CLI warnings
Modern Testing Support Web Test Runner, Vitest CLI setup
Router Enhancements Async redirects, scroll options, custom elements See above
Dynamic Two-Way Binding For runtime-created components Dynamic component APIs

Angular 20 is a transformative release, making Angular apps more reactive, performant, and developer-friendly. For enterprise teams and solo devs alike, these features offer new ways to build scalable, modern web applications.

Top comments (1)

Collapse
 
geromegrignon profile image
Gérôme Grignon

No Signal Forms and Selectorless components in v20