Which Mode Should I Use?

Both modes plug into NgOptimizedImage via Angular's IMAGE_LOADER token. The difference is when and where images are processed.

CriteriaSSR / DynamicAOT / Build
DeploymentNode server (Express, custom SSR)Static hosting (GitHub Pages, Netlify, Vercel static)
ProcessingOn first request via Sharp middlewareOnce at build time via CLI
Runtime overheadCPU per unique image × widthNone — files are pre-generated
User uploadsYes — new URLs optimized on demandNo — only assets present at build time
Peer dependencysharp on the serversharp only for the build step

Choose SSR / Dynamic when…

  • Your app runs Angular SSR with an Express (or compatible) server.
  • Image sources change at runtime (CMS content, avatars, user uploads).
  • You want format negotiation (WebP/AVIF) without rebuilding the site.

Continue to SSR setup →

Choose AOT / Build when…

  • You deploy a static browser bundle with no image-processing server.
  • All images live in public/ or are copied into the dist at build time.
  • You want predictable asset URLs and zero cold-start latency on first view.

Continue to AOT setup →

Can I switch later? Yes — swap the provider in app.config.ts and add or remove the server middleware / postbuild script. The ng add schematic accepts --mode=SSR or --mode=AOT for a guided setup.