Installation
Prerequisites
- Node.js 18+
- Angular 18+ with
NgOptimizedImage - SSR mode: Angular SSR with an Express server entry (
server.ts) - AOT mode: A production build pipeline (no runtime server required for images)
Quick start (schematic)
The fastest path is ng add, which installs dependencies and wires the correct provider for your chosen mode:
bash
ng add ng-image-optimizer --mode=SSRbash
ng add ng-image-optimizer --mode=AOTManual install
bash
npm install ng-image-optimizer sharpsharp is required for SSR middleware and for the AOT CLI. It is listed as an optional dependency but should be installed explicitly in your app.
After install
Complete mode-specific setup — only one path applies to your app: