
Auth0 Angular
Add Auth0 login, route guards, and HTTP interceptors to an Angular 13+ SPA with @auth0/auth0-angular.
Overview
auth0-angular is an agent skill for the Build phase that integrates @auth0/auth0-angular into Angular SPAs with guards and interceptors.
Install
npx skills add https://github.com/auth0/agent-skills --skill auth0-angularWhat is this skill?
- Official @auth0/auth0-angular SDK install and AuthModule configuration
- Environment-based domain, clientId, and redirect_uri setup
- Route guards and HTTP interceptors for protected SPA routes
- Auth0 CLI automated setup path via references/setup.md
- Explicit exclusions: AngularJS 1.x, mobile RN, and backend-only JWT validation
- Requires Angular 13 or newer per skill prerequisites
Adoption & trust: 520 installs on skills.sh; 26 GitHub stars; 2/3 security scanners passed (skills.sh audits).
What problem does it solve?
You have an Angular app without production-ready login, and ad-hoc OAuth snippets risk misconfigured redirects and unprotected routes.
Who is it for?
Solo builders shipping Angular 13+ web apps who already have or will create an Auth0 application and want SDK-aligned SPA auth.
Skip if: AngularJS 1.x apps, React Native or Ionic mobile clients, or APIs that only need server-side JWT validation without an Angular frontend.
When should I use this skill?
Adding authentication to Angular applications with route guards and HTTP interceptors using @auth0/auth0-angular.
What do I get? / Deliverables
Your Angular SPA has Auth0 SDK wiring, environment config, and guard/interceptor patterns so users sign in and API calls carry tokens correctly.
- Installed @auth0/auth0-angular dependency and Auth module configuration
- environment.ts Auth0 domain, clientId, and redirect_uri settings
- Route guard and HTTP interceptor patterns for protected SPA behavior
Recommended Skills
Journey fit
Authentication integration happens during product build when the SPA needs real login flows before ship-ready environments. Integrations subphase covers third-party SDK wiring—Auth module, environment config, and guards—not generic UI layout.
How it compares
Frontend SPA Auth0 SDK skill—not backend middleware; pair with auth0-quickstart if the tenant is not configured yet.
Common Questions / FAQ
Who is auth0-angular for?
Indie developers and small teams building Angular SPAs who need Auth0-hosted authentication with route protection and token-aware HTTP calls.
When should I use auth0-angular?
During Build integrations when implementing login UX and protected routes in Angular 13+, after Auth0 tenant setup (often via auth0-quickstart).
Is auth0-angular safe to install?
It documents official Auth0 SDK usage; review the Security Audits panel on this page and never commit live client secrets—use environment config and Auth0 dashboard settings.
Workflow Chain
Requires first: auth0 quickstart
SKILL.md
READMESKILL.md - Auth0 Angular
# Auth0 Angular Integration Add authentication to Angular applications using @auth0/auth0-angular. --- ## Prerequisites - Angular 13+ application - Auth0 account and application configured - If you don't have Auth0 set up yet, use the `auth0-quickstart` skill first ## When NOT to Use - **AngularJS (1.x)** - This SDK requires Angular 13+, use legacy solutions for AngularJS - **Mobile applications** - Use `auth0-react-native` for React Native or native SDKs for Ionic - **Backend APIs** - Use JWT validation middleware for your server language --- ## Quick Start Workflow ### 1. Install SDK ```bash npm install @auth0/auth0-angular ``` ### 2. Configure Environment **For automated setup with Auth0 CLI**, see [Setup Guide](references/setup.md) for complete scripts. **For manual setup:** Update `src/environments/environment.ts`: ```typescript export const environment = { production: false, auth0: { domain: 'your-tenant.auth0.com', clientId: 'your-client-id', authorizationParams: { redirect_uri: window.location.origin } } }; ``` ### 3. Configure Auth Module **For standalone components (Angular 14+):** Update `src/app/app.config.ts`: ```typescript import { ApplicationConfig } from '@angular/core'; import { provideAuth0 } from '@auth0/auth0-angular'; import { environment } from '../environments/environment'; export const appConfig: ApplicationConfig = { providers: [ provideAuth0({ domain: environment.auth0.domain, clientId: environment.auth0.clientId, authorizationParams: environment.auth0.authorizationParams }) ] }; ``` **For NgModule-based apps:** Update `src/app/app.module.ts`: ```typescript import { AuthModule } from '@auth0/auth0-angular'; import { environment } from '../environments/environment'; @NgModule({ imports: [ AuthModule.forRoot({ domain: environment.auth0.domain, clientId: environment.auth0.clientId, authorizationParams: environment.auth0.authorizationParams }) ] }) export class AppModule {} ``` ### 4. Add Authentication UI Update `src/app/app.component.ts`: ```typescript import { Component } from '@angular/core'; import { AuthService } from '@auth0/auth0-angular'; @Component({ selector: 'app-root', template: ` <div *ngIf="auth.isLoading$ | async; else loaded"> <p>Loading...</p> </div> <ng-template #loaded> <ng-container *ngIf="auth.isAuthenticated$ | async; else loggedOut"> <div *ngIf="auth.user$ | async as user"> <img [src]="user.picture" [alt]="user.name" /> <h2>Welcome, {{ user.name }}!</h2> <button (click)="logout()">Logout</button> </div> </ng-container> <ng-template #loggedOut"> <button (click)="login()">Login</button> </ng-template> </ng-template> ` }) export class AppComponent { constructor(public auth: AuthService) {} login(): void { this.auth.loginWithRedirect(); } logout(): void { this.auth.logout({ logoutParams: { returnTo: window.location.origin } }); } } ``` ### 5. Test Authentication Start your dev server and test the login flow: ```bash ng serve ``` --- ## Detailed Documentation - **[Setup Guide](references/setup.md)** - Automated setup scripts (Bash/PowerShell), CLI commands, manual configuration - **[Integration Guide](references/integration.md)** - Protected routes with guards, HTTP interceptors, error handling - **[API Reference](references/api.md)** - Complete SDK API, configuration options, services reference, testing strategies --- ## Common Mistakes | Mistake | Fix | |---------|-----| | Forgot to add