ng-awesome-node-auth

raw JSON →
1.8.4 verified Fri May 01 auth: no javascript

Angular (v21+) standalone library providing interceptors, guards, and session management for backends using awesome-node-auth. v1.8.4, actively maintained. Key differentiators: fully tree-shakable, reactive signals for user state, smart guards (authGuard/guestGuard), automatic CSRF protection, optional UI sync for themes and feature flags, and SSR compatibility. Integrates seamlessly with Angular 21's standalone APIs via provideAuth and provideAuthUi providers.

error NullInjectorError: No provider for _HttpClient!
cause Missing HttpClientModule or provideHttpClient() in the app providers.
fix
Add provideHttpClient() in your app.config.ts: import { provideHttpClient } from '@angular/common/http'; then add to providers array.
error TypeError: Cannot read properties of undefined (reading 'pipe')
cause Attempting to use the library without appropriate Angular version or missing peer dependencies.
fix
Ensure @angular/core and @angular/common are at version ^21.2.0 and run 'npm install' again.
error Cannot find module 'ng-awesome-node-auth' or its corresponding type declarations.
cause Package not installed or missing from node_modules.
fix
Run 'npm install ng-awesome-node-auth' and verify your tsconfig.json includes 'node_modules' in 'moduleResolution'.
breaking Minimum Angular version 21.2.0 is required.
fix Upgrade to Angular 21.2.0 or later.
gotcha provideAuth() must be called exactly once per application; calling it multiple times may cause token refresh conflicts.
fix Ensure provideAuth is only provided in the root ApplicationConfig.
gotcha The interceptors only attach tokens to requests matching the configured apiPrefix; other requests are ignored.
fix Set apiPrefix to match your backend's authentication endpoints, e.g., '/api/auth'.
deprecated Using the library with Angular 20 or below is not supported; peer dependencies enforce Angular 21.
fix Use an older version (<1.0.0) if you must stay on Angular 20, but no support is guaranteed.
npm install ng-awesome-node-auth
yarn add ng-awesome-node-auth
pnpm add ng-awesome-node-auth

Shows how to configure ng-awesome-node-auth in an Angular 21 application using provideAuth and provideAuthUi, and protects routes with authGuard and guestGuard.

import { ApplicationConfig } from '@angular/core';
import { provideRouter } from '@angular/router';
import { provideAuth, provideAuthUi, authGuard, guestGuard } from 'ng-awesome-node-auth';
import { LoginComponent, DashboardComponent } from './components';

export const appConfig: ApplicationConfig = {
  providers: [
    provideRouter([
      { path: 'login', component: LoginComponent, canActivate: [guestGuard] },
      { path: 'dashboard', component: DashboardComponent, canActivate: [authGuard] }
    ]),
    provideAuth({ apiPrefix: '/api/auth' }),
    provideAuthUi(),
  ]
};