ngx-fastboot

raw JSON →
2.1.0 verified Fri May 01 auth: no javascript

ngx-fastboot is an Angular library for dynamically loading configuration at runtime, optimizing startup performance by lazy-loading providers. The current stable version is 2.1.0, released February 2025. It requires Angular 19 and Node >=20.10.0. Key differentiators: unlike typical static environment files, ngx-fastboot allows configurations to be loaded asynchronously via HTTP or custom sources and bundled into a separate chunk for faster initial loads. It provides fastBootstrapApplication, withProviders, and lazyRootComponent helpers. The library ships TypeScript types and follows Angular's standalone component pattern.

error Error: NG0203: inject() must be called from an injection context
cause Attempting to use inject() outside of an injection context, e.g., in a factory function not called by Angular.
fix
Ensure config loader functions are passed to withProviders, not called directly in providers array.
error Error: No provider for InjectionToken APP_CONFIG
cause The configuration was not loaded when component tried to inject APP_CONFIG, likely because withProviders was not used or the config loading failed.
fix
Use withProviders to load config before app bootstrap, and handle fetch errors.
breaking Angular 18 no longer supported in v2.0.0
fix Upgrade to Angular 19 or stay on v1.x for Angular 18 support.
breaking v2.0.0 replaced bootstrapApplication with fastBootstrapApplication. Old API no longer works.
fix Use fastBootstrapApplication instead of bootstrapApplication when using ngx-fastboot.
deprecated withProviders was renamed from provideFastBoot in older versions; the old name is deprecated.
fix Use withProviders instead of provideFastBoot.
gotcha fastBootstrapApplication expects providers array with withProviders, not a direct call. If you forget withProviders, config won't load.
fix Wrap config loader in withProviders() and include in providers array.
npm install ngx-fastboot
yarn add ngx-fastboot
pnpm add ngx-fastboot

Bootstraps an Angular app with lazy configuration loaded via HTTP. Uses fastBootstrapApplication and withProviders to defer config providers.

import { fastBootstrapApplication, withProviders } from 'ngx-fastboot';
import { provideHttpClient } from '@angular/common/http';
import { AppComponent } from './app.component';

// Config loader factory - must return a promise of providers
const configProviders = () =>
  fetch('/config.json').then(res => res.json()).then(config => [
    { provide: 'APP_CONFIG', useValue: config },
  ]);

// Bootstrap
fastBootstrapApplication(AppComponent, {
  providers: [
    provideHttpClient(),
    withProviders(configProviders), // lazy-loaded providers
  ],
});