agentsclimarketplace

Ng22 routing lazy

Skill PavanAnguluri/angular22-agent-skills/skills/ng22-routing-lazy

Angular 22 Agent Skills

Install
npx -y skills add PavanAnguluri/angular22-agent-skills --skill ng22-routing-lazy

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Prescribes Angular 22 route design, lazy loading, guards, and route-level composition.

SKILL.md

2.7 KB, as published. Nobody here has run it

Angular 22 Routing & Lazy Loading

Design routes as the primary composition boundary for large applications. Load feature code lazily and keep route definitions explicit, typed, and small.

Core Rules

  1. Use loadComponent() and loadChildren() for feature isolation.
  2. Keep route guards functional and side-effect free whenever possible.
  3. Put route-specific providers on the route record instead of in a global shell.
  4. Use route data only for stable metadata such as titles, permissions, and display hints.
  5. Favor child routes over runtime template branching when the URL represents a true navigation state.
  6. Keep route configuration shallow and easy to scan.

Example

import { Routes } from '@angular/router';
import { authGuard } from './auth.guard';

export const routes: Routes = [
  {
    path: '',
    loadComponent: () => import('./home/home.component').then((m) => m.HomeComponent),
    title: 'Home',
  },
  {
    path: 'account',
    canActivate: [authGuard],
    providers: [],
    loadChildren: () => import('./account/account.routes').then((m) => m.ACCOUNT_ROUTES),
  },
  {
    path: 'admin',
    loadChildren: () => import('./admin/admin.routes').then((m) => m.ADMIN_ROUTES),
    data: { requiresAuth: true, section: 'admin' },
  },
];

Guard and Resolver Guidance

import { CanActivateFn, Router } from '@angular/router';
import { inject } from '@angular/core';

export const authGuard: CanActivateFn = () => {
  const router = inject(Router);
  const isAuthenticated = true;

  return isAuthenticated ? true : router.parseUrl('/login');
};

Use resolvers only when the UI cannot render without preloaded data. Prefer skeletons or deferred content when the page can render immediately and hydrate data later.

Lazy Loading Best Practices

  • Prefer route-level lazy loading over bundle-wide eager imports.
  • Keep redirects and wildcard routes at the edge of the route tree.
  • Use child routes for nested navigation states instead of template branching.
  • Put page titles and permission hints in data, not business logic.
  • Keep guard logic fast so navigation stays responsive.

Anti-Patterns

  • Do not make route files a dumping ground for unrelated app logic.
  • Do not read remote data in a guard unless navigation truly depends on it.
  • Do not duplicate the same authorization logic in both route data and component code.

Review Checklist

  • Each major feature has a lazy-loaded boundary.
  • Guards are small and predictable.
  • Route metadata is static and easy to audit.
  • Route structure mirrors product navigation.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.