AbsoluteJS

Change Detection

Angular pages in AbsoluteJS run zoneless by default. Apps and libraries that rely on zone.js can opt every page into zone change detection with one config key.

#Zoneless by Default

With no config, pages render on the server and hydrate in the browser without zone.js. Change detection runs after template events and signal updates. Use signals for state that changes outside a template event, such as a value set in a timer.

Code written for zone.js often sets a plain field from a timer or a manually added event listener. In a zoneless page that change doesn't paint on its own, and the server renders the field's first value.

TS
import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'status-page',
  standalone: true,
  template: `
    <p>{{ status }}</p>
    <button (click)="later()">Update later</button>
  `
})
export class StatusComponent implements OnInit {
  status = 'init';

  ngOnInit() {
    setTimeout(() => {
      this.status = 'ready';
    }, 50);
  }

  later() {
    setTimeout(() => {
      this.status = 'updated';
    }, 50);
  }
}

#Zone Mode

Add zone.js to your app, then set angular.changeDetection to 'zone' in absolute.config.ts. The setting applies to every Angular page. The other value is 'zoneless', the default.

BASH
bun add zone.js
TS
// absolute.config.ts
import { defineConfig } from '@absolutejs/absolute';

export default defineConfig({
  angular: { changeDetection: 'zone' },
  angularDirectory: 'src/frontend/angular'
});

With this config the component above renders ready on the server, and the button's delayed update paints in the browser. Hydration and HMR keep working, and Elysia routes on the same server are unaffected.

#What Changes

AspectZonelessZone
Server renderSends the page once the first render settlesWaits for the timers and HttpClient requests the page starts
Plain field set in a timerNot painted until something else runs change detectionPainted
NgZoneNo-op zoneNgZone
BrowserAngular boots without zone.jszone.js loads before Angular boots

zone.js can't follow native await. In zone mode AbsoluteJS compiles the async functions in your Angular code to generators, so work after an await stays in the zone and the server waits for it.

TS
import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'report-page',
  standalone: true,
  template: `<p>{{ status }}</p>`
})
export class ReportComponent implements OnInit {
  status = 'loading';

  // In zone mode the server waits for this before it sends the page,
  // so the HTML already says "loaded".
  async ngOnInit() {
    await new Promise((resolve) => setTimeout(resolve, 100));
    this.status = 'loaded';
  }
}

zone.js tracks HttpClient requests but not a raw fetch(). Use HttpClient for requests the server render should wait for.

#Islands

Angular islands render zoneless in both modes. Write island state with signals so it updates the same way on any host page.

#@defer Streaming

AbsoluteJS streams Angular @defer blocks. The server sends the page with each block's @placeholder, then streams the resolved block into the same response. Deferred sections stay in place after the page hydrates.

HTML
<!-- frontend/angular/templates/dashboard.html -->
<h1>{{ stats.visits }} visits</h1>

@defer (on timer(300ms)) {
  <activity-feed />
} @placeholder {
  <p>Loading activity…</p>
}

Streaming needs collectStreamingSlots: true on the page handler. Without it the block stays on its placeholder during the server render, and AbsoluteJS logs a warning that names the option.

TS
// backend/server.ts
import { asset } from '@absolutejs/absolute';
import { handleAngularPageRequest } from '@absolutejs/absolute/angular';
import type * as DashboardPage from '../frontend/angular/pages/dashboard';

new Elysia().get('/dashboard', async () =>
  handleAngularPageRequest<DashboardPage.Context>({
    collectStreamingSlots: true,
    indexPath: asset(manifest, 'DashboardIndex'),
    pagePath: asset(manifest, 'Dashboard'),
    requestContext: { stats: await getStats() }
  })
);