{"id":46109579,"url":"https://github.com/lumentut/ngx-history","last_synced_at":"2026-03-13T17:00:47.250Z","repository":{"id":57310965,"uuid":"317489703","full_name":"lumentut/ngx-history","owner":"lumentut","description":"A simple and small Angular navigation history module","archived":false,"fork":false,"pushed_at":"2026-02-17T15:09:11.000Z","size":581,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-02-17T18:48:09.385Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lumentut.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}},"created_at":"2020-12-01T09:28:15.000Z","updated_at":"2026-02-17T15:09:14.000Z","dependencies_parsed_at":"2022-08-26T06:52:19.558Z","dependency_job_id":null,"html_url":"https://github.com/lumentut/ngx-history","commit_stats":null,"previous_names":["lumentut/ngx-history","yohaneslumentut/ngx-history"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lumentut/ngx-history","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lumentut%2Fngx-history","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lumentut%2Fngx-history/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lumentut%2Fngx-history/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lumentut%2Fngx-history/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lumentut","download_url":"https://codeload.github.com/lumentut/ngx-history/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lumentut%2Fngx-history/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30471114,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-13T11:00:43.441Z","status":"ssl_error","status_checked_at":"2026-03-13T11:00:23.173Z","response_time":60,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2026-03-01T22:00:55.626Z","updated_at":"2026-03-13T17:00:47.243Z","avatar_url":"https://github.com/lumentut.png","language":"TypeScript","funding_links":[],"categories":["Third Party Components"],"sub_categories":["Router"],"readme":"# NgxHistory\n\n[![Live Demo](https://img.shields.io/badge/🚀_Live_Demo-blue?style=for-the-badge)](https://lumentut.github.io/ngx-history/)\n\n\u003ca href=\"https://github.com/lumentut/ngx-history/actions/workflows/deploy-demo.yml\"\u003e\n  \u003cimg src=\"https://github.com/lumentut/ngx-history/actions/workflows/deploy-demo.yml/badge.svg\" alt=\"CI status\" /\u003e\n\u003c/a\u003e\u0026nbsp;\n\u003ca href=\"https://www.npmjs.com/package/ngx-history\"\u003e\n  \u003cimg src=\"https://img.shields.io/npm/v/ngx-history.svg?logo=npm\u0026logoColor=fff\u0026label=NPM+package\u0026color=limegreen\" alt=\"ngx-history on npm\" /\u003e\n\u003c/a\u003e\u0026nbsp;\n\u003ca href=\"https://github.com/lumentut/ngx-history/blob/master/LICENSE\"\u003e\n  \u003cimg src=\"https://img.shields.io/npm/l/ngx-history.svg?color=blue\" alt=\"MIT License\" /\u003e\n\u003c/a\u003e\u0026nbsp;\n\u003ca href=\"https://lumentut.github.io/ngx-history/\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/demo-online-brightgreen.svg\" alt=\"Demo\" /\u003e\n\u003c/a\u003e\n\n\u003e **Modern Angular navigation history service with reactive programming support**\n\n`NgxHistory` is a lightweight Angular service that provides browser-like navigation history functionality with full TypeScript support and reactive programming patterns. Build intuitive navigation experiences in your Angular applications with observables, state tracking, and seamless router integration.\n\n✨ **Features:**\n\n- 🎯 **Angular 21+ Support** - Built with the latest Angular features\n- 🔄 **Reactive Programming** - Observable streams with RxJS integration\n- 📊 **State Tracking** - Real-time navigation state with `NavigationState` interface\n- 🚀 **Zero Configuration** - Works out of the box with `providedIn: 'root'`\n- 📱 **TypeScript First** - Complete type safety and IntelliSense support\n- ⚡ **Tree Shakeable** - Minimal bundle size impact\n- 🔙 **Browser-like Navigation** - Familiar back/forward functionality\n- 🧪 **Well Tested** - Comprehensive test coverage\n- 🎛️ **Flexible Setup** - NgModule, Standalone, or direct injection\n- 🔥 **New APIs** - Signals, observables, and async/await patterns\n\n## 🚀 Quick Start\n\n### Installation\n\n```bash\nnpm install ngx-history\n# or\nyarn add ngx-history\n# or\npnpm install ngx-history\n```\n\n### Basic Usage\n\n```typescript\nimport { Component } from \"@angular/core\";\nimport { HistoryService } from \"ngx-history\";\n\n@Component({\n  selector: \"app-navigation\",\n  template: `\n    \u003cdiv class=\"nav-controls\"\u003e\n      \u003cbutton [disabled]=\"!navigationState.canGoBack\" (click)=\"historyService.goBack()\"\u003e← Back\u003c/button\u003e\n\n      \u003cbutton [disabled]=\"!navigationState.canGoForward\" (click)=\"historyService.goForward()\"\u003eForward →\u003c/button\u003e\n\n      \u003cspan class=\"current-path\"\u003e\n        {{ navigationState.currentPath }}\n      \u003c/span\u003e\n    \u003c/div\u003e\n  `,\n})\nexport class NavigationComponent {\n  navigationState = this.historyService.navigationState();\n\n  constructor(public historyService: HistoryService) {}\n}\n```\n\n## 📚 Usage Examples\n\n### 1. Traditional NgModule Approach\n\n```typescript\n// app.module.ts\nimport { NgModule } from \"@angular/core\";\nimport { NgxHistoryModule } from \"ngx-history\";\n\n@NgModule({\n  imports: [\n    // Basic usage - no configuration needed\n    NgxHistoryModule,\n\n    // Or with custom configuration\n    NgxHistoryModule.forRoot({\n      maxHistoryLength: 100,\n      debugMode: true,\n      defaultRoute: \"/dashboard\",\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\n### 2. Standalone/Modern Angular Approach\n\n```typescript\n// main.ts\nimport { bootstrapApplication } from \"@angular/platform-browser\";\nimport { HISTORY_CONFIG } from \"ngx-history\";\n\nbootstrapApplication(AppComponent, {\n  providers: [\n    // Optional configuration\n    {\n      provide: HISTORY_CONFIG,\n      useValue: {\n        maxHistoryLength: 50,\n        debugMode: false,\n      },\n    },\n    // HistoryService auto-provided via 'root'\n  ],\n});\n```\n\n### 3. Component with Subscriptions\n\n```typescript\nimport { Component, OnInit, OnDestroy } from \"@angular/core\";\nimport { HistoryService, NavigationError } from \"ngx-history\";\nimport { Subscription } from \"rxjs\";\n\n@Component({\n  selector: \"app-smart-nav\",\n  template: `\n    \u003cdiv class=\"navigation\"\u003e\n      \u003c!-- Navigation controls --\u003e\n      \u003cbutton [disabled]=\"!canGoBack\" (click)=\"goBack()\"\u003e← Back\u003c/button\u003e\n\n      \u003cbutton [disabled]=\"!canGoForward\" (click)=\"goForward()\"\u003eForward →\u003c/button\u003e\n\n      \u003c!-- Error display --\u003e\n      \u003cdiv *ngFor=\"let error of errors\" class=\"error\"\u003e\n        {{ error.message }}\n      \u003c/div\u003e\n    \u003c/div\u003e\n  `,\n})\nexport class SmartNavigationComponent implements OnInit, OnDestroy {\n  canGoBack = false;\n  canGoForward = false;\n  errors: NavigationError[] = [];\n\n  private subscription = new Subscription();\n\n  constructor(private historyService: HistoryService) {}\n\n  ngOnInit() {\n    // Subscribe to navigation state\n    this.subscription.add(\n      this.historyService.navigationState$.subscribe((state) =\u003e {\n        this.canGoBack = state.canGoBack;\n        this.canGoForward = state.canGoForward;\n      }),\n    );\n\n    // Subscribe to navigation errors\n    this.subscription.add(\n      this.historyService.navigationError$.subscribe((error) =\u003e {\n        this.errors = [...this.errors, error].slice(-3); // Keep last 3\n      }),\n    );\n  }\n\n  ngOnDestroy() {\n    this.subscription.unsubscribe();\n  }\n\n  async goBack() {\n    await this.historyService.goBack();\n  }\n\n  async goForward() {\n    await this.historyService.goForward();\n  }\n}\n```\n\n### Reactive Programming Example\n\n```typescript\nimport { Component, OnInit } from \"@angular/core\";\nimport { HistoryService, NavigationState } from \"ngx-history\";\nimport { Observable } from \"rxjs\";\n\n@Component({\n  selector: \"app-smart-navigation\",\n  template: `\n    \u003cdiv *ngIf=\"navigationState$ | async as state\"\u003e\n      \u003cdiv class=\"history-info\"\u003e\n        \u003cp\u003eCurrent: {{ state.currentPath }}\u003c/p\u003e\n        \u003cp\u003eHistory Length: {{ state.historyLength }}\u003c/p\u003e\n        \u003cp\u003eCan Go Back: {{ state.canGoBack }}\u003c/p\u003e\n        \u003cp\u003eCan Go Forward: {{ state.canGoForward }}\u003c/p\u003e\n      \u003c/div\u003e\n\n      \u003cdiv class=\"navigation-controls\"\u003e\n        \u003cbutton [disabled]=\"!state.canGoBack\" (click)=\"historyService.goBack()\" class=\"nav-btn\"\u003e← Previous\u003c/button\u003e\n\n        \u003cbutton [disabled]=\"!state.canGoForward\" (click)=\"historyService.goForward()\" class=\"nav-btn\"\u003eNext →\u003c/button\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n  `,\n})\nexport class SmartNavigationComponent implements OnInit {\n  navigationState$!: Observable\u003cNavigationState\u003e;\n\n  constructor(private historyService: HistoryService) {}\n\n  ngOnInit(): void {\n    // Subscribe to navigation state changes\n    this.navigationState$ = this.historyService.navigationState$;\n\n    // React to state changes\n    this.navigationState$.subscribe((state) =\u003e {\n      console.log(\"Navigation state changed:\", state);\n      // Implement custom logic based on navigation state\n    });\n  }\n}\n```\n\n## 📖 API Documentation\n\n### HistoryService\n\nThe main service providing navigation history functionality.\n\n#### Properties\n\n| Property           | Type                          | Description                                   |\n| ------------------ | ----------------------------- | --------------------------------------------- |\n| `navigationState$` | `Observable\u003cNavigationState\u003e` | Observable stream of navigation state changes |\n\n#### Methods\n\n| Method              | Return Type               | Description                                                      |\n| ------------------- | ------------------------- | ---------------------------------------------------------------- |\n| `navigationState()` | `Signal\u003cNavigationState\u003e` | Angular signal for current navigation state                      |\n| `goBack()`          | `boolean`                 | Navigate to previous page. Returns `true` if navigation occurred |\n| `goForward()`       | `boolean`                 | Navigate to next page. Returns `true` if navigation occurred     |\n| `canGoBack()`       | `boolean`                 | Check if backward navigation is possible                         |\n| `canGoForward()`    | `boolean`                 | Check if forward navigation is possible                          |\n\n### NavigationState Interface\n\nComplete navigation state information.\n\n```typescript\ninterface NavigationState {\n  canGoBack: boolean; // Whether backward navigation is possible\n  canGoForward: boolean; // Whether forward navigation is possible\n  currentPath: string; // Current route path\n  historyLength: number; // Number of entries in history\n}\n```\n\n## 🎮 Demo Application\n\nExplore a comprehensive demo showcasing NgxHistory features:\n\n**[🚀 Live Demo](https://lumentut.github.io/ngx-history/)**\n\nThe demo includes:\n\n- Real-time navigation state visualization\n- Interactive back/forward controls\n- Multiple page navigation examples\n- Reactive programming patterns\n- TypeScript usage examples\n\n## 🔄 Migration Guide\n\n### From v1.x to v2.0\n\nNgxHistory v2.0 introduces breaking changes for Angular 21+ support:\n\n#### Before (v1.x)\n\n```typescript\n// Old module import required\nimport { NgxHistoryModule } from \"ngx-history\";\n\n@NgModule({\n  imports: [NgxHistoryModule],\n})\nexport class AppModule {}\n\n// Old API\nconst canGoBack = this.historyService.canGoBack;\nconst canGoForward = this.historyService.canGoForward;\n```\n\n#### After (v2.0)\n\n```typescript\n// No module import needed - service uses providedIn: 'root'\nimport { HistoryService } from \"ngx-history\";\n\n// New reactive API\nconst navigationState = this.historyService.navigationState();\nconst canGoBack = navigationState.canGoBack;\nconst canGoForward = navigationState.canGoForward;\n\n// Or use observables\nthis.historyService.navigationState$.subscribe((state) =\u003e {\n  console.log(\"State:\", state);\n});\n```\n\n#### Breaking Changes\n\n- **Angular 15+ Required** - Minimum Angular version increased\n- **API Changes** - New reactive API with signals and observables\n- **Module Removal** - No need to import `NgxHistoryModule`\n- **TypeScript Updates** - Enhanced type definitions\n\n#### Migration Steps\n\n1. Update to Angular 15+\n2. Remove `NgxHistoryModule` imports\n3. Update service usage to new API\n4. Test navigation functionality\n\n## 🛠️ Development\n\n### Requirements\n\n- Node.js 20.11+\n- Angular 21+\n- TypeScript 5.9+\n\n### Setup\n\n```bash\ngit clone https://github.com/lumentut/ngx-history.git\ncd ngx-history\nnpm install\n\n# Build library\nnpm run build\n\n# Run tests\nnpm test\n\n# Build demo\nng build ngx-history-demo\n```\n\n## 🤝 Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## 📋 Requirements\n\n- **Angular**: 21.0.0 or higher\n- **RxJS**: 7.0.0 or higher\n- **TypeScript**: 5.0.0 or higher\n\n## 📄 License\n\nThis project is licensed under the [MIT License](LICENSE) - see the LICENSE file for details.\n\n## 🏷️ Version History\n\n- **v2.0.0** - Angular 21+ support, reactive programming, TypeScript modernization\n- **v1.x** - Legacy Angular 11-14 support (maintenance mode)\n\n---\n\n**Made with ❤️ by [Yohanes Lumentut](https://github.com/lumentut)**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flumentut%2Fngx-history","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flumentut%2Fngx-history","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flumentut%2Fngx-history/lists"}