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.
Common errors
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.
Warnings
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.
Install
npm install ngx-fastboot yarn add ngx-fastboot pnpm add ngx-fastboot Imports
- fastBootstrapApplication wrong
import fastBootstrapApplication from 'ngx-fastboot';correctimport { fastBootstrapApplication } from 'ngx-fastboot'; - withProviders wrong
import { WithProviders } from 'ngx-fastboot';correctimport { withProviders } from 'ngx-fastboot'; - lazyRootComponent wrong
import { LazyRootComponent } from 'ngx-fastboot';correctimport { lazyRootComponent } from 'ngx-fastboot'; - type AppConfig wrong
import { AppConfig } from 'ngx-fastboot';correctimport type { AppConfig } from 'ngx-fastboot';
Quickstart
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
],
});