Article Angular

Article

Zoneless by Default: What Angular 21 Changes in Practice

Angular 21 makes zoneless change detection the default. Here is what changes, what to remove, and how to prepare an established app.

2 min read Angular

Angular 21 made zoneless change detection the default. For a new application, that is intentionally uneventful: there is no provider to add. For an existing application, it is a useful architectural checkpoint.

The old default depended on Zone.js patching browser APIs and telling Angular that “something may have changed.” Zoneless Angular instead relies on explicit notifications from Angular APIs and its rendering model. Signals, template-bound state, AsyncPipe, input updates, event listeners, and ChangeDetectorRef.markForCheck() all participate in that model.

What a new Angular 21 app needs

Nothing special. Do not add provideZonelessChangeDetection() to an Angular 21+ bootstrap just to make it zoneless; it is already the default.

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

That is zoneless in Angular 21. First check that the app is not opting back into Zone.js behavior with provideZoneChangeDetection().

The migration is really about notification points

Most modern Angular applications are close already. Problems tend to appear where a component mutates a plain field from a callback Angular cannot observe.

// Fragile: a third-party callback changes plain state.
chart.onPointSelected((point) => {
  this.selectedPoint = point;
});

Make the state observable to Angular instead:

readonly selectedPoint = signal<Point | null>(null);

chart.onPointSelected((point) => {
  this.selectedPoint.set(point);
});

Signals are not mandatory everywhere. markForCheck() is still appropriate when integrating an imperative library into a component that uses OnPush:

chart.onPointSelected((point) => {
  this.selectedPoint = point;
  this.changeDetectorRef.markForCheck();
});

The important rule is that an async boundary must notify Angular. Avoid papering over missed notifications with NgZone.run() or manual detectChanges() unless that boundary truly requires it.

Remove Zone.js only after the app is clean

Once the app runs correctly zoneless, remove zone.js and zone.js/testing from the build and test polyfills (or from the corresponding polyfills.ts imports), then remove the package:

npm uninstall zone.js

Do this in a small pull request after checking browser behavior, third-party widgets, and tests. Removing Zone.js reduces a source of monkey-patching and maintenance, but it is the final cleanup—not the first migration step.

Tests should wait for stability

The test smell most likely to surface is a suite that repeatedly calls fixture.detectChanges() after every state change. In zoneless tests, prefer “act, wait, assert”:

component.name.set('Ada');

await fixture.whenStable();

expect(fixture.nativeElement.textContent).toContain('Ada');

That matches how production rendering is scheduled and makes tests less dependent on implementation timing.

Zoneless is a major default change, not a demand to rewrite every component in signals tomorrow. Audit external callbacks, make state updates visible to Angular, and remove Zone.js once the app has earned that cleanup. Angular’s zoneless guide documents the supported notification mechanisms and the precise removal steps.

Related articles

Keep reading

Search

Search the publication

Search articles and topic pages without leaving the page.