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

@nicolabello/ng-dynamic-router

v3.0.0

Published

Mobile-style stacked navigation for Angular: animated forward/back transitions, history-aware back button and query-param driven subviews.

Readme

@nicolabello/ng-dynamic-router

npm License: GPL v2+

Mobile-style stacked navigation for the Angular Router:

  • Pages slide in from the right when navigating forward and from the left when going back (including the browser back button)
  • Every page knows its parent page, so a "back" button is only shown when it makes sense and never leaves the app
  • Subviews (e.g. a details panel or a dialog) are stored in the URL query string, so they survive reloads and are closed with the back button
  • Per-page and per-subview query params, encoded in the URL
  • canDeactivate support for pages and subviews (e.g. "discard changes?")

Compatibility

| @nicolabello/ng-dynamic-router | Angular | | ------------------------------ | ------- | | 3.x | 22 | | 2.x | 18 |

The transitions use @angular/animations, so the application must provide animations (e.g. provideAnimationsAsync()).

Installation

npm install @nicolabello/ng-dynamic-router

Setup

  1. Wrap the routes that should be animated with dynamicRoute():
import { Routes } from '@angular/router';

import { dynamicRoute } from '@nicolabello/ng-dynamic-router';

export const routes: Routes = [
  dynamicRoute({ path: 'products', component: ProductListComponent }),
  dynamicRoute({ path: 'products/:id', component: ProductComponent }),
  { path: '', redirectTo: 'products', pathMatch: 'full' },
];
  1. Provide the router and the dynamic router (forRoot() replaces the LocationStrategy to track the navigation direction):
import { importProvidersFrom } from '@angular/core';
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
import { provideRouter } from '@angular/router';

import { DynamicRouterModule } from '@nicolabello/ng-dynamic-router';

bootstrapApplication(AppComponent, {
  providers: [provideRouter(routes), provideAnimationsAsync(), importProvidersFrom(DynamicRouterModule.forRoot())],
});

In NgModule applications, import DynamicRouterModule.forRoot() in the root module and DynamicRouterModule.forChild() in feature modules.

  1. Use <nb-dynamic-router-outlet> instead of <router-outlet>:
import { DynamicRouterOutletComponent } from '@nicolabello/ng-dynamic-router';

@Component({
  selector: 'app-root',
  imports: [DynamicRouterOutletComponent],
  template: `<nb-dynamic-router-outlet />`,
})
export class AppComponent {}

Navigation

Use the nbDynamicRouterLink directive or DynamicRouterService. Navigating with them records the current page as the parent of the new one.

import { AsyncPipe } from '@angular/common';
import { Component, inject } from '@angular/core';

import { DynamicRouterLinkDirective, DynamicRouterService } from '@nicolabello/ng-dynamic-router';

@Component({
  selector: 'app-product',
  imports: [AsyncPipe, DynamicRouterLinkDirective],
  template: `
    @if (router.backAllowed | async) {
      <button (click)="router.goBack()">Back</button>
    }
    <a [nbDynamicRouterLink]="['/products', 2]">Next product</a>
  `,
})
export class ProductComponent {
  protected router = inject(DynamicRouterService);
}

| DynamicRouterService member | Description | | ---------------------------------------------------------------------- | ------------------------------------------------------------------------------- | | navigate(commands, extras?) | Navigates forward (same arguments as Router.navigate) | | goBack() | Goes back to the parent page, if there is one | | backAllowed | Observable<boolean>: whether the current page has a parent | | animating | Observable<boolean>: whether a transition is running | | navigationDirection | Direction of the last navigation (NavigationDirection.Forward / Backward) | | isActive(url) | Observable<boolean>: whether url is the current page | | globalParams / globalQueryParams | Route params and query params of the current page (plus ...Snapshot versions) | | queryParams / setQueryParam(key, value) / setQueryParams(params) | Query params scoped to the current page or subview, encoded in the URL |

The nbDynamicRouterLinkActive pipe tells whether a link is active, e.g. [class.active]="['/products'] | nbDynamicRouterLinkActive | async".

Subviews

A subview is a named view (for example a details panel) whose state is kept in the query string (?s1=details&q1=...), so it can be opened, closed with the back button and restored on reload.

<nb-dynamic-router-subview #subview>
  @if (subview.active === 'filters') {
  <app-filters />
  }
</nb-dynamic-router-subview>
// Open the "filters" subview of the first level, with some params
this.router.showSubview(1, 'filters', { category: 'books' });

// Close it (goes back in the history)
this.router.hideSubview(1);

// React when it is closed
this.router.subviewHidden(1).subscribe((subview) => console.log(`${subview} closed`));

Components inside <nb-dynamic-router-subview> get a DynamicRouterService scoped to the subview level: their queryParams and setQueryParam() read and write the params of that subview. Subviews can be nested.

Preventing navigation

Implement CanComponentDeactivate and register the component as the active one for its level:

import { Observable, of } from 'rxjs';

import { CanComponentDeactivate, DynamicRouterService } from '@nicolabello/ng-dynamic-router';

export class EditProductComponent implements CanComponentDeactivate {
  private router = inject(DynamicRouterService);

  public constructor() {
    this.router.setActiveComponent(this);
  }

  public canDeactivate(): Observable<boolean> {
    return of(!this.form.dirty || confirm('Discard changes?'));
  }
}

canDeactivate() is called when leaving the page, or when closing the subview the component is in.

License

GPL-2.0-or-later