npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ngx-runtime-initializer

v1.0.5

Published

Angular package for loading runtime configuration, managing app settings, and injecting services with post-initialization callbacks, compatible with standalone Angular 19+ applications.

Downloads

9

Readme

Ngx Runtime Initializer

npm version License: MIT

NgxRuntimeInitializer is an Angular utility for loading runtime configuration from JSON, managing global app settings, and optionally injecting services with post-initialization callbacks. Perfect for SSR, feature toggles, and dynamic environment configuration.


Features

  • Load runtime configuration (config.json or custom URL) at app initialization.
  • Validate essential properties (apiURL, debug, requestTimeout).
  • Inject services into post-initialization logic.
  • Support fallback configuration on failure.
  • Provides Angular signals for reactive configuration.
  • Built-in guards for maintenance mode or app status handling.

Installation

Install via npm:

npm install ngx-runtime-initializer

Usage

1. Define your runtime config JSON

// config.json
{
  "coreConfig": {
    "apiURL": "https://api.example.com",
    "debug": true,
    "requestTimeout": 30000
  },
  "status": true
}

2. Provide the runtime initializer in standalone bootstrap

import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app/app.component';
import { provideRuntimeInitializer } from 'ngx-runtime-initializer';

bootstrapApplication(AppComponent, {
  providers: [provideRuntimeInitializer()],
});

✅ Loads config.json with default behavior.


3. Custom initialization

import { RuntimeInitializerOptions, provideRuntimeInitializer } from 'ngx-runtime-initializer';
import { MyService1, MyService2 } from './services';

bootstrapApplication(AppComponent, {
  providers: [
    provideRuntimeInitializer(
      new RuntimeInitializerOptions(
        '/assets/runtime-config.json',
        [MyService1, MyService2],
        async (config, services) => {
          console.log('Config loaded:', config);
          services.MyService1?.initialize();
        },
        (error, services) => {
          console.warn('Failed to initialize runtime config:', error);
        }
      )
    ),
  ],
});

4. Accessing configuration

import { inject } from '@angular/core';
import { AppConfigService } from 'ngx-runtime-initializer';

const appConfigService = inject(AppConfigService);

// Full config
const config = appConfigService.getConfig();

// Specific property
const apiURL = appConfigService.getConfigProperty<string>('coreConfig')?.apiURL;

// Reactive signal
const configSignal = appConfigService.getConfigSignal();

5. Guards for maintenance and status

import { InMaintenanceGuard, MaintenanceGuard, createStatusGuard } from 'ngx-runtime-initializer';

{
  path: 'maintenance',
  canActivate: [InMaintenanceGuard]
}

{
  path: '',
  canActivate: [MaintenanceGuard]
}

// Or create a custom guard
{
  path: 'custom',
  canActivate: [createStatusGuard(true, '/maintenance')]
}

API

RuntimeInitializerOptions

Class to configure the runtime initializer.

Constructor

new RuntimeInitializerOptions(
  configUrl?: string,
  servicesToInject?: Type<any>[],
  postInit?: (config: AppConfig, services: Record<string, any>) => Promise<void>,
  handleInitializationFailure?: (error: any, services: Record<string, any>) => void
)

Defaults:

  • configUrl = 'config.json'
  • servicesToInject = []
  • postInit = async () => {}
  • handleInitializationFailure = () => {}

provideRuntimeInitializer(options?: RuntimeInitializerOptions)

Provides an Angular provideAppInitializer — equivalent to APP_INITIALIZER in pre-standalone Angular versions — to load runtime configuration.


AppConfigService

  • getConfig(): AppConfig — Returns full config.
  • getConfigProperty<T>(key: keyof AppConfig): T | undefined — Returns a specific property.
  • getConfigSignal(): WritableSignal<AppConfig> — Reactive configuration.
  • getStatus(): boolean — Returns app status.

AppConfig

Default configuration class:

coreConfig = { apiURL: '__BACKEND__', debug: false, requestTimeout: 30000 };
status = false;

License

This project is licensed under the MIT License - see the LICENSE file for details.