{"id":17691429,"url":"https://github.com/aleksanderbodurri/ngx-runtime-env","last_synced_at":"2025-09-22T21:05:02.603Z","repository":{"id":42394360,"uuid":"384868553","full_name":"AleksanderBodurri/ngx-runtime-env","owner":"AleksanderBodurri","description":"Runtime environment solution for Angular","archived":false,"fork":false,"pushed_at":"2023-08-24T06:00:18.000Z","size":471,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-14T15:59:50.701Z","etag":null,"topics":["angular"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AleksanderBodurri.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-11T05:36:50.000Z","updated_at":"2025-02-19T09:47:33.000Z","dependencies_parsed_at":"2024-10-24T14:33:14.830Z","dependency_job_id":"dc495008-8498-41d3-b157-bb5085633e2d","html_url":"https://github.com/AleksanderBodurri/ngx-runtime-env","commit_stats":{"total_commits":27,"total_committers":4,"mean_commits":6.75,"dds":"0.11111111111111116","last_synced_commit":"189d20af9de084e19910e0a52b9e1b88e1f47e13"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/AleksanderBodurri/ngx-runtime-env","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AleksanderBodurri%2Fngx-runtime-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AleksanderBodurri%2Fngx-runtime-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AleksanderBodurri%2Fngx-runtime-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AleksanderBodurri%2Fngx-runtime-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AleksanderBodurri","download_url":"https://codeload.github.com/AleksanderBodurri/ngx-runtime-env/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AleksanderBodurri%2Fngx-runtime-env/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276473928,"owners_count":25648790,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-22T02:00:08.972Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular"],"created_at":"2024-10-24T12:08:44.151Z","updated_at":"2025-09-22T21:05:02.563Z","avatar_url":"https://github.com/AleksanderBodurri.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/AleksanderBodurri/ngx-runtime-env/raw/main/logo.svg?\" alt=\"ngx-runtime-env\" width=\"350\"/\u003e\n\u003c/p\u003e\n\n# What problem does this library solve?\n\nMany Angular applications depend on configuration to modify application behaviour. You may want multiple instances of the same Angular app to behave differently based on some configuration. Angular provides [a way to do this at build time](https://angular.io/guide/build#configuring-application-environments) but often this solution is not flexible enough if engineers want to configure their app after it's been built/deployed.\n\n`ngx-runtime-env` solves this. It fetches an application environment at runtime, and then mutates the existing Angular environment accordingly. See [Usage](#usage) for an example.\n\n[![npm version](https://badge.fury.io/js/ngx-runtime-env.svg)](https://badge.fury.io/js/ngx-runtime-env)\n[![AleksanderBodurri](https://circleci.com/gh/AleksanderBodurri/ngx-runtime-env.svg?style=svg)](https://app.circleci.com/pipelines/github/AleksanderBodurri/ngx-runtime-env)\n\n# Install\n```\nnpm i ngx-runtime-env\n```\nor\n```\nyarn add ngx-runtime-env\n```\n\n# Usage\n\nIn: `src/environments/environment.ts` (static)\n\n```ts\nexport const environment = {\n  production: false,\n  foo: 'bar',\n};\n\n```\n\nIn:  `assets/environment.json` (dynamic, picked up at runtime, will mutate static environment)\n```json\n{\n    \"production\": true,\n    \"foo\": \"baz\",\n}\n```\n\nIn: `app.module.ts`\n```ts\nimport { BrowserModule } from '@angular/platform-browser';\nimport { NgModule } from '@angular/core';\nimport { AppComponent } from './app.component';\nimport { HttpClientModule } from '@angular/common/http';\nimport { RuntimeEnvModule } from 'ngx-runtime-env';\nimport { environment } from '../environments/environment';\n\n@NgModule({\n  declarations: [ AppComponent ],\n  imports: [ \n    BrowserModule,\n    // import HttpClientModule\n    HttpClientModule,\n    // import RuntimeEnvModule module and pass in static environment\n    RuntimeEnvModule.forRoot(environment)\n  ],\n  providers: [],\n  bootstrap: [ AppComponent ]\n})\nexport class AppModule {}\n```\n\nIn a component (`app.component.ts` for example)\n```ts\nimport { Component, OnInit } from '@angular/core';\nimport { environment } from 'src/environments/environment';\n\n@Component({\n  selector: 'app-root',\n  templateUrl: './app.component.html',\n  styleUrls: ['./app.component.scss']\n})\nexport class AppComponent implements OnInit {\n\n  ngOnInit(): void {\n    console.log(environment.production); // true\n    console.log(environment.foo); // baz\n  }\n}\n\n```\n\n# Configuration\n\n| Name  | Type  | Default  | Description |\n|---|---|---|---|\n| envUrl  | string  | `assets/environment.json`  | Specify where the runtime environment can be found.  |\n|  bootstrapAppModule | `'before' \\| 'after'`  | `'after'`  | Whether to bootstrap the application module before or after the runtime environment is loaded.  |\n| optional  | boolean | false | If true, application will bootstrap normally even if runtime environment fails to be found |\n\n### Example\n\nIn: `app.module.ts`\n```ts\nimport { BrowserModule } from '@angular/platform-browser';\nimport { NgModule } from '@angular/core';\nimport { AppComponent } from './app.component';\nimport { HttpClientModule } from '@angular/common/http';\nimport { RuntimeEnvModule } from 'ngx-runtime-env';\nimport { environment } from '../environments/environment';\n\n@NgModule({\n  declarations: [ AppComponent ],\n  imports: [ \n    BrowserModule,\n    HttpClientModule,\n    RuntimeEnvModule.forRoot(environment, {\n      envUrl: '/path/to/my/config', // looks for runtime environment in envUrl\n      bootstrapAppModule: 'before' // does not wait for runtime environment to bootstrap App Module\n    })\n  ],\n  providers: [],\n  bootstrap: [ AppComponent ]\n})\nexport class AppModule {}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faleksanderbodurri%2Fngx-runtime-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faleksanderbodurri%2Fngx-runtime-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faleksanderbodurri%2Fngx-runtime-env/lists"}