Skip to content

Angular

Scope: web apps built with Angular 22, the current major version (released on 3 June 2026), with standalone components, signals, the Angular CLI and, where used, Angular's server-side rendering. Angular 21 still gets critical and security fixes in long-term support until June 2027; Angular 20's support ended on 28 November 2026, and older versions are no longer supported. From version 22 on, a new major version ships every 12 months instead of every 6 (Angular, Versioning and releases). Framework-independent rules for accessibility, performance, security and testing (WEB-*) are in Web front end, and the compiler settings (TS-*) in TypeScript. The Node.js server that renders pages for server-side rendering is backend code, so the Node.js and Security guidelines also apply to it.

Entries are sorted by score from 1 to 10 (criteria): 9โ€“10 start here or strongly recommended, 6โ€“8 recommended, 1โ€“5 further reading or conditional.

Adopted references

  • 9 Angular documentation: the baseline. The essentials and in-depth guides to components, templates, signals, dependency injection, routing, forms, the HTTP client, server-side and hybrid rendering, testing and internationalization, and the best-practice pages on security, accessibility and performance.
  • 8 Angular coding style guide: the official Angular-specific conventions: file names that match the class inside, such as user-profile.ts for UserProfile, one concept per file, folders by feature instead of by type, inject() instead of constructor injection, and components that focus on presentation.
  • 8 Angular, Security: Angular's XSS model and sanitization, Content Security Policy and Trusted Types, XSRF protection in HttpClient, and, for server-side rendering, allowed host names and trusted proxy headers against server-side request forgery.
  • 8 Angular, Server-side and hybrid rendering: choosing a rendering mode, server routes with a render mode per route, prerendering, the HTTP transfer cache, and writing components that also run on the server.
  • 7 Angular, Signals: writable and computed signals, reactive contexts and read-only signals, with guides to linkedSignal, resources and effects.
  • 7 Angular, Performance: when to use each loading technique (lazy-loaded routes, @defer, lazy-loaded services, image optimization and server-side rendering) and each runtime technique (zoneless change detection, slow computations, skipping component subtrees and profiling).
  • 7 Angular, Versioning and releases: the release schedule, the support window of 12 months active and 12 months long-term support, the supported versions, the deprecation policy and the supported update paths.
  • 7 Angular Update Guide: step-by-step instructions for an update between two versions, filtered by the app's complexity and dependencies such as Angular Material.
  • 7 Angular, Accessibility: ARIA bindings, building on native elements, focus management and active links after routing, and the accessible components in Angular Material, the CDK and Angular Aria.
  • 7 Angular, Testing: unit tests with Vitest, the default runner for new projects, tests in a real browser, code coverage, CI, and guides to testing components, services, routing and HTTP and to component harnesses.
  • 6 Angular CLI: creating, building, serving, testing and updating apps with ng, plus builders and schematics. The esbuild-based application builder is the default, and the webpack-based browser builder is deprecated.

Key rules

Components and reactivity

  • 7 ANGULAR-1 Keep the current defaults in new code: standalone components, OnPush change detection and zoneless change detection. Don't set standalone: false, ChangeDetectionStrategy.Eager or provideZoneChangeDetection(). The Angular team recommends standalone components instead of NgModules for all new code, components are OnPush by default since version 22, and apps are zoneless by default since version 21. (Angular, NgModules, Skipping component subtrees: using OnPush, Zoneless: enabling zoneless)
  • 7 ANGULAR-2 Derive state with computed(), or with linkedSignal() when the user can also set it, and use effect() only to sync signals with APIs that aren't reactive, such as storage, logging, or a canvas or third-party UI library. Copying one signal into another with an effect can cause ExpressionChangedAfterItHasBeenChecked errors, circular updates and extra change detection. (Angular, Use cases for effects, Dependent state with linkedSignal)
  • 6 ANGULAR-3 Declare inputs, outputs and queries with the signal-based functions, such as input(), output(), model() and viewChild(), and name outputs in camelCase, without an on prefix and without the name of a DOM event such as click. The decorator-based APIs remain supported, but the Angular team recommends the functions for new projects. (Angular, Accepting data with input properties, Outputs: choosing event names, Queries)
  • 6 ANGULAR-4 Use the built-in control flow (@if, @for and @switch) instead of the deprecated *ngIf, *ngFor and *ngSwitch, and give every @for a track expression with a property that uniquely identifies the item, such as its ID. Track by $index only for collections that never change, and avoid tracking the item itself, which can make updates much slower. (Angular, Why is track in @for blocks important?, NgIf)

Services and state

Routing and rendering

Security

  • 9 ANGULAR-11 Never use route guards as access control: check authorization on the server for every request. Guards only decide what the browser shows, and users can change any JavaScript that runs in their browser. This applies SEC-1 in Security, and Authentication covers sessions and tokens. (Angular, Control route access with guards)
  • 9 ANGULAR-12 Never build Angular templates from user input: ship only templates that the CLI compiles ahead of time, and don't generate Angular templates with a server-side templating language. Angular treats templates as trusted, executable code, so injected template syntax gives an attacker full control of the app. (Angular, Security: XSS security model, Use the AOT template compiler, Server-side XSS protection)
  • 9 ANGULAR-13 Insert untrusted values through template bindings, so that Angular sanitizes them, never pass them to the DomSanitizer.bypassSecurityTrust*() methods, and don't write to the DOM through ElementRef.nativeElement or document. Where direct DOM access can't be avoided, sanitize values with DomSanitizer.sanitize() and the matching SecurityContext. This is how an Angular app applies WEB-8. (Angular, Sanitization and security contexts, Trusting safe values, Direct use of the DOM APIs)
  • 9 ANGULAR-14 Never put secrets, such as API keys, in the files in src/environments/: the build bundles them into the client, where anyone who loads the page can read them. Keep secrets on a server, for example behind a proxy. This applies SEC-11. (Angular, Build environments)
  • 7 ANGULAR-15 Send a Content Security Policy with a unique, unpredictable nonce for each response, and pass the nonce to Angular with the ngCspNonce attribute or the CSP_NONCE token. On static hosting that can't add a nonce, turn on autoCsp or avoid inline scripts, instead of hard-coding a nonce. Also enforce Trusted Types with Angular's angular policy. This is how an Angular app applies WEB-10. (Angular, Content security policy, Hash inline scripts with autoCsp, Enforcing Trusted Types)

Build, tooling and upgrades

  • 8 ANGULAR-16 Run a major version that is still supported, update with ng update one major version at a time, and plan each yearly major update before your version's long-term support ends. ng update also runs the code migrations for the new version. This applies SEC-17. (Angular, Actively supported versions, Breaking change policy and update paths, ng update)
  • 7 ANGULAR-17 Keep strict template type checking on (strictTemplates, the default) together with TypeScript's strict (TS-1), and make the extended diagnostics fail the build by setting their defaultCategory to error. Extended diagnostics find mistakes such as signals that aren't called in interpolations and track functions that aren't called, but by default they are only warnings. (Angular, Template type checking: strict mode, Extended diagnostics: configuration)

Testing

How to enforce

Tools that check the key rules above automatically, in CI, the IDE or a commit hook. "Partly" means the tool covers only some of what the rule asks.

Tutorials and further reading

  • 7 Learn Angular: the official interactive tutorial, which teaches Angular's building blocks step by step in the browser.
  • 6 Build your first Angular app (Angular): the official tutorial for building a small app locally with the CLI, also available as a video course.
  • 6 Learn Angular signals (Angular): an interactive tutorial on signals and building reactive apps with them.