Full answer
Migrating to standalone is a step by step process with a schematic, not a rewrite. Prepare first: update to a recent Angular version with ng update, make sure the build and tests pass, and commit.
Run ng generate @angular/core:standalone and choose the mode. The recommended order:
- Convert all components, directives and pipes to standalone. The schematic sets
standalone: truewhere needed (or removes the flag in newer versions where it is the default), moves their template dependencies intoimports, and updates the modules that declared them. Build, run tests, and commit. - Remove unnecessary NgModule classes. Modules that now only re-export or import other things can be deleted. The schematic keeps modules that have providers or routing configuration it cannot safely remove. Build, test, commit.
- Bootstrap the project using standalone APIs. It replaces
platformBrowserDynamic().bootstrapModule(AppModule)withbootstrapApplication(AppComponent, appConfig), and moves providers (HttpClientModulebecomesprovideHttpClient(),RouterModule.forRootbecomesprovideRouter). Build, test, run the app, commit.
After the schematic, finish by hand: remove unused modules, check lazy routes (loadChildren to a module still works, and can be changed to loadComponent or a routes array), review the imports arrays for unused entries, and fix tests that used declarations. Large apps can migrate a folder at a time using the path option.
Common problems: modules with forRoot() providers need manual conversion to provider functions, a third party library that is still module-based is imported by its module (this is fine), entryComponents leftovers, and schematics skipping files with unusual patterns (check the log).
Other helpful migrations in the same style: @angular/core:control-flow (templates to @if, @for, @switch), @angular/core:inject (constructor injection to inject()), @angular/core:signal-input-migration, output-migration, and signal-queries-migration. Run them one at a time, with a clean commit between runs, so review stays easy.
Standalone is optional to adopt, and NgModules still work, but new Angular features and documentation assume standalone.
import { ApplicationConfig, provideBrowserGlobalErrorListeners } from '@angular/core';
import { provideHttpClient } from '@angular/common/http';
import { provideRouter, Routes } from '@angular/router';
// Before (module based main.ts):
// platformBrowserDynamic().bootstrapModule(AppModule);
// AppModule imports: BrowserModule, HttpClientModule, RouterModule.forRoot(routes)
//
// After step 3 (standalone):
const routes: Routes = [];
export const appConfig: ApplicationConfig = {
providers: [
provideBrowserGlobalErrorListeners(),
provideRouter(routes), // was RouterModule.forRoot(routes)
provideHttpClient(), // was HttpClientModule
],
};
// main.ts: bootstrapApplication(AppComponent, appConfig).catch(console.error);This describes the Angular CLI schematics for Angular 20. The schematics were not run here. The sample shows the result shape of step 3 (a standalone bootstrap), and it was type-checked.
Key points
- Run `ng generate @angular/core:standalone` three times: convert, prune modules, switch bootstrap.
- Build, test and commit after each step.
- Finish by hand: `forRoot` providers, lazy routes, unused imports and test setup.
- Other schematics migrate control flow, `inject()`, signal inputs, outputs and queries.
Common mistakes
- Running all steps in one commit, so problems are hard to trace.
- Expecting the schematic to rewrite `forRoot()` providers.
- Migrating without updating Angular first.
Follow-ups
- How do you migrate only one feature folder?
- What happens to lazy loaded modules?
- Which other schematics would you run next?
Tips
- Give the three modes in order and one check per step.
- Say that commits stay small.
- Mention the manual parts honestly.
Evaluation rubric
- States the schematic steps in the right order.
- Describes checks and manual follow-up.
- Names related migrations.