Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk4 min

APP_INITIALIZER in Angular: What It Does and How to Replace It with provideAppInitializer

APP_INITIALIZER runs functions at Angular application startup and waits for Promises or Observables. Here is how it works, how to migrate to provideAppInitializer, and how it differs from the platform and environment initializers.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

APP_INITIALIZER is the dependency-injection token Angular uses to run functions during application startup, and Angular now recommends provideAppInitializer() in its place. If an initializer returns a Promise or an Observable, Angular holds initialization until the Promise resolves or the Observable completes. Angular’s API reference checked in October 2026 marks the token deprecated since v19.0.

What APP_INITIALIZER does

APP_INITIALIZER is a multi-provider token. You register one or more initializer functions under it, and Angular calls them while the application starts. Angular’s APP_INITIALIZER API reference describes the behavior this way: “The provided functions are injected at application startup and executed during app initialization.”

As an Amazon Associate I earn from qualifying purchases.

Two behaviors matter when you write one:

  • Startup gating. A returned Promise must resolve, or a returned Observable must complete, before initialization finishes. Work you return is work the app waits for.
  • Injection context. Initializers run in an injection context, so you can call inject() inside the function to get dependencies.

The legacy pattern

In older code, the initializer is registered as a provider object with provide: APP_INITIALIZER and multi: true. A typical registration looks like this:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
{
  provide: APP_INITIALIZER,
  useFactory: (config: ConfigService) => () => config.load(),
  deps: [ConfigService],
  multi: true,
}

The factory receives its dependencies through deps, and it returns the function Angular will execute at startup.

Replacing it with provideAppInitializer

The current API is provideAppInitializer(initializerFn). It returns EnvironmentProviders and runs the supplied function at application startup. The same registration becomes:

provideAppInitializer(() => {
  const config = inject(ConfigService);
  return config.load();
})

Angular’s own example uses this shape to load configuration over HTTP before the app starts. It calls inject(HttpClient) inside the initializer and converts the request with firstValueFrom:

bootstrapApplication(App, {
  providers: [
    provideAppInitializer(() => {
      const http = inject(HttpClient);
      return firstValueFrom(http.get('/api/config'));
    }),
    provideHttpClient(),
  ],
});

Angular’s provideAppInitializer reference adds: “Note that the provided initializer is run in the injection context.”

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Migration steps

  1. Search the project for APP_INITIALIZER in providers arrays, NgModule providers lists, and test setups.
  2. In an application bootstrapped with bootstrapApplication, replace each { provide: APP_INITIALIZER, ... } object with a provideAppInitializer() call in the same providers array.
  3. Move each entry from deps into an inject() call at the top of the function body. Remove the deps array and the multi flag.
  4. Confirm the function returns a Promise that resolves, or an Observable that completes, when the startup work is finished.
  5. Start the app and check that the code that depended on the loaded data runs only after the initializer finishes.

NgModule applications can keep the legacy token. Angular’s documentation presents it as a legacy pattern and does not require moving to standalone bootstrapping to adopt provideAppInitializer.

Async behavior: Promises and Observables

Angular accepts a Promise or an Observable from an application initializer and waits on either one. For a Promise, the wait ends when it resolves. For an Observable, the wait ends when the stream completes, not when it emits its first value.

This has a practical consequence. An Observable that never completes keeps initialization pending. This follows from the documented completion rule rather than from a separate example in Angular’s reference, so design the stream to complete once the required work is done. Use firstValueFrom or lastValueFrom when you want a one-shot request, or add take(1) to a long-lived stream.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Three initializer APIs and their scopes

The names are similar, but each API runs at a different point in the lifecycle. Pick the one that matches when your code needs to run.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Lifecycle scope Provider function Legacy token Function signature and async contract Provider form
Application startup provideAppInitializer APP_INITIALIZER (deprecated since v19.0) Can return a Promise or Observable; Angular waits for resolution or completion EnvironmentProviders
Platform injector setup providePlatformInitializer Legacy platform initializer token Documented as () => void; no async wait StaticProvider
Environment injector construction provideEnvironmentInitializer ENVIRONMENT_INITIALIZER (deprecated since v19.0) Documented as () => void; no async wait EnvironmentProviders

Use providePlatformInitializer and provideEnvironmentInitializer only when your code must run at those lower-level points. Neither is a drop-in substitute for application startup work that needs to be awaited.

Deprecation timing

The APP_INITIALIZER reference marks the token deprecated since v19.0 but does not name a removal release. Angular’s versioning and releases policy says deprecated APIs remain available through at least the next major release and may be removed after that deprecation period. Check the release notes for the Angular version you deploy before planning a removal date, because the policy describes a window rather than a fixed version.

For new code, use provideAppInitializer now. For existing NgModule code that works, there is no urgency to rewrite it on the strength of the deprecation alone.

Checklist before you ship

  • Every initializer returns a Promise that resolves or an Observable that completes.
  • No initializer depends on a value that a later initializer is supposed to provide, since the order of your startup work should be explicit.
  • Dependencies are obtained with inject() inside the function, not captured from outside it.
  • Platform and environment initializers are used only where the lifecycle requires them.

“

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.