Skip to content

Angular Components and Angular SSR

@awc-ui/angular provides standalone component proxies and Angular form value accessors. Component proxy imports register their custom elements automatically.

Use Angular 20.3.31 or newer. The wrapper and examples use the patched Angular 20 compiler and runtime; applications on Angular 17–19 must upgrade Angular before updating the wrapper.

Terminal window
npm install @awc-ui/angular @awc-ui/core

Load the theme once in your application entry:

import '@awc-ui/core/css/tokens.css';

For a standalone component, import the controls and accessors into its template scope, alongside Angular’s forms module:

import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { MdButton, MdTextField, TextValueAccessor } from '@awc-ui/angular';
@Component({
selector: 'app-root',
standalone: true,
imports: [FormsModule, MdButton, MdTextField, TextValueAccessor],
template: `
<md-text-field label="Email" type="email" [(ngModel)]="email"></md-text-field>
<md-button variant="filled">Continue</md-button>
`,
})
export class AppComponent {
email = '';
}

For convenience, imports: [FormsModule, AwcUiModule] supplies every component and accessor. Use ReactiveFormsModule for formControl and formControlName. NgModule applications also put AwcUiModule in imports.

importProvidersFrom(AwcUiModule) does not add directives to a standalone component’s template scope. provideAwcUi() is a compatibility adapter for the Core lazy loader.

Applications that manage raw custom-element registration can import form accessors from @awc-ui/angular/forms. This entry avoids importing the full component proxy registry and uses the same SSR-aware directives as the main Angular entry:

import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { TextValueAccessor } from '@awc-ui/angular/forms';
import '@awc-ui/core/components/md-text-field';
@Component({
selector: 'app-root',
standalone: true,
imports: [FormsModule, TextValueAccessor],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `<md-text-field label="Email" [(ngModel)]="email"></md-text-field>`,
})
export class AppComponent {
email = '';
}

Register every Core element used by the template. The forms entry does not provide typed component proxies or their ordinary-input SSR serialization; when using raw tags, supply non-form initial state through server-renderable attributes. Keep SSR-capable components/* imports for SSR and prerendering. The main @awc-ui/angular entry and AwcUiModule remain supported.

Radio controls bind the selected option’s value, preserving each radio’s identity. Import both MdRadio and RadioValueAccessor for individual imports:

<md-radio name="plan" value="basic" [(ngModel)]="plan">Basic</md-radio>
<md-radio name="plan" value="pro" [(ngModel)]="plan">Pro</md-radio>

Initialize plan to 'basic' or 'pro'; resetting the form to null clears the selection. Multi-select accessors normalize a form reset to an empty array.

Angular can server-render the surrounding application normally. AWC UI’s @awc-ui/core/hydrate module then transforms the rendered md-* markup into Declarative Shadow DOM, preserving styles and content in the server response. On the client, Angular proxies or direct Core imports register the elements and hydrate that server-rendered output.

Typed proxies from @awc-ui/angular serialize ordinary input bindings such as [label], [value] and [selected] using Core’s declared attribute names, including custom aliases. Supported option/item/node arrays use JSON attributes, and selection arrays use the same initial-value seed as forms. Callback and other property-only inputs stay out of the HTML. On the client, bindings continue to update properties without adding synthetic events or reflecting extra attributes.

The form accessors from either Angular entry point serialize initial form values before Core transforms the server HTML. Text, numeric, checked, selected and disabled values reach the first paint, and radio options keep their own identity. Array selections use the shared data-awc-initial-values seed, including an explicit empty array. Browser accessors continue to write properties and emit no synthetic change events during hydration.

Initial form state is rendered without interaction animations. Subsequent model updates and user actions still update the controls normally. For the shared rules on first paint, class preservation, and deploying matching server/client Core builds, follow the SSR guide.

Forward the request’s BootstrapContext when bootstrapping on the server. Angular uses it to keep the platform injector scoped to that request:

src/main.server.ts
import { bootstrapApplication, type BootstrapContext } from '@angular/platform-browser';
import { AppComponent } from './app/app.component';
import { config } from './app/app.config.server';
export default (context: BootstrapContext) =>
bootstrapApplication(AppComponent, config, context);

For a custom Node server, import CommonEngine from @angular/ssr/node.

The repository includes a validated Angular SSR reference app and a multi-route Angular SSR showcase. Read the shared SSR guide for the transform options and framework support matrix.