{"id":28436231,"url":"https://github.com/eurusik/ngx-remote-component","last_synced_at":"2025-09-13T19:28:58.109Z","repository":{"id":296432849,"uuid":"993410222","full_name":"eurusik/ngx-remote-component","owner":"eurusik","description":"An Angular library for loading remote components dynamically in Nx workspaces.","archived":false,"fork":false,"pushed_at":"2025-06-04T10:51:50.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-14T03:03:42.516Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eurusik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2025-05-30T18:36:28.000Z","updated_at":"2025-06-04T10:51:51.000Z","dependencies_parsed_at":"2025-05-31T01:05:58.792Z","dependency_job_id":"17921e03-a34f-4bc5-9bed-43889e90a7df","html_url":"https://github.com/eurusik/ngx-remote-component","commit_stats":null,"previous_names":["eurusik/ngx-remote-component"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eurusik/ngx-remote-component","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eurusik%2Fngx-remote-component","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eurusik%2Fngx-remote-component/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eurusik%2Fngx-remote-component/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eurusik%2Fngx-remote-component/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eurusik","download_url":"https://codeload.github.com/eurusik/ngx-remote-component/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eurusik%2Fngx-remote-component/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275016789,"owners_count":25391171,"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-13T02:00:10.085Z","response_time":70,"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":[],"created_at":"2025-06-05T21:42:05.102Z","updated_at":"2025-09-13T19:28:57.914Z","avatar_url":"https://github.com/eurusik.png","language":"TypeScript","readme":"# ngx-remote-component\n\nAn Angular library for loading remote components dynamically in Nx workspaces.\n\n\u003e **Important**: This library is specifically designed for use with [Nx](https://nx.dev/) workspaces and Module Federation. It is not intended for use with standalone Angular applications or other workspace structures.\n\n### Recommended Module Federation Loader\n\nThis library is designed to work with Nx workspaces and Module Federation. Strongly recommend using the [`ngx-mf-remote-loader`](https://github.com/eurusik/ngx-mf-remote-loader) package for Module Federation support\n\n## Usage\n\n### 1. Configure the module\n\n```typescript\nimport { NgModule } from '@angular/core';\nimport { RemoteComponentModule, REMOTE_COMPONENT_LOADER } from 'ngx-remote-component';\nimport { RemoteLoaderBrowser, RemoteLoaderServer } from 'ngx-mf-remote-loader';\nimport { isPlatformBrowser } from '@angular/common';\nimport { PLATFORM_ID, Inject } from '@angular/core';\n\n@NgModule({\n  imports: [\n    RemoteComponentModule\n  ],\n  providers: [\n    {\n      provide: REMOTE_COMPONENT_LOADER,\n      useFactory: (platformId: Object) =\u003e {\n        // Use RemoteLoaderBrowser for browser environments\n        if (isPlatformBrowser(platformId)) {\n          return new RemoteLoaderBrowser();\n        }\n        // Use RemoteLoaderServer for server-side rendering\n        return new RemoteLoaderServer();\n      },\n      deps: [PLATFORM_ID]\n    }\n  ]\n})\nexport class AppModule { }\n```\n\n### 2. Set up Module Federation\n\nCreate a `module-federation.config.ts` file next to your application's `webpack.config.ts` file:\n\n```typescript\nimport { ModuleFederationConfig } from '@nx/module-federation';\n\nconst config: ModuleFederationConfig = {\n  name: 'my-remote-app',\n  exposes: {\n    './Module': 'apps/my-remote-app/src/app/remote-entry/entry.module.ts',\n    './MyComponent': 'apps/my-remote-app/src/app/remote-entry/components/my-component.ts'\n  }\n};\n\nexport default config;\n```\n\n### 3. Create wrapper components for remote components\n\nPlace your wrapper components in the `remote-entry` directory of your application (e.g., `apps/my-app/src/app/remote-entry`). These wrapper components should expose your actual components to be consumed remotely:\n\n```typescript\nimport { ChangeDetectionStrategy, Component, input } from '@angular/core'\nimport { ProductCardComponent } from '@my-org/product-components'\nimport { ProductAnalyticsParams } from '@my-org/analytics'\nimport { ProductModifierModel } from '@my-org/core-models'\n\n@Component({\n  selector: 'my-app-remote-product-card',\n  imports: [ProductCardComponent],\n  template: `\n    \u003cmy-org-product-card\n      [class]=\"className()\"\n      [productId]=\"productId()\"\n      [productParams]=\"productParams()\"\n    /\u003e\n  `,\n  changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class RemoteComponent {\n  readonly productId = input.required\u003c{ id: string }\u003e()\n  readonly productParams = input.required\u003cany\u003e()\n}\n```\n\nThen expose this component in your `module-federation.config.ts` file:\n\n```typescript\nimport { ModuleFederationConfig } from '@nx/module-federation';\n\nconst config: ModuleFederationConfig = {\n  name: 'my-app',\n  exposes: {\n    './Module': 'apps/my-app/src/app/remote-entry/entry.module.ts',\n    './ProductCard': 'apps/my-app/src/app/remote-entry/product-card/remote.component.ts'\n  }\n};\n\nexport default config;\n```\n\n### 4. Use the directive in your templates\n\n```html\n\u003cdiv \n  ngxRemoteComponent\n  [remoteName]=\"'my-app'\"\n  [componentName]=\"'ProductCard'\"\n  [inputs]=\"{ \n    productId: { id: '12345' },\n    productParams: { quantity: 1, price: 19.99 }\n  }\"\n  (outputs)=\"handleOutputs($event)\"\u003e\n\u003c/div\u003e\n```\n\n### 4. Handle outputs in your component\n\n```typescript\nimport { Component } from '@angular/core';\n\n@Component({\n  selector: 'app-root',\n  templateUrl: './app.component.html'\n})\nexport class AppComponent {\n  myData = { foo: 'bar' };\n  \n  handleOutputs(outputs: Record\u003cstring, any\u003e) {\n    // Handle outputs from the remote component\n    console.log('Output received:', outputs);\n    \n    // Example: Handle a specific output\n    if ('buttonClick' in outputs) {\n      console.log('Button clicked with data:', outputs['buttonClick']);\n    }\n  }\n}\n```\n\n## API Reference\n\n### RemoteComponentLoaderDirective\n\nA directive for loading remote components.\n\n#### Inputs\n\n- `remoteName` (required): The name of the remote application\n- `componentName` (required): The name of the component to load\n- `inputs`: An object containing inputs to pass to the remote component\n\n#### Outputs\n\n- `outputs`: An EventEmitter that emits when any output from the remote component is triggered\n\n### RemoteComponentLoader\n\nAn interface for implementing remote component loading.\n\n#### Methods\n\n- `load(remote: string, component: string): Promise\u003cany\u003e`: Load a remote component\n\n## License\n\nMIT\n","funding_links":[],"categories":["Architecture and Advanced Topics"],"sub_categories":["Module Federation"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feurusik%2Fngx-remote-component","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feurusik%2Fngx-remote-component","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feurusik%2Fngx-remote-component/lists"}