
Angular Interceptors
This covers Angular's modern functional HTTP interceptors, which replaced the old class-based approach in recent versions. You'll use it when you need to inject auth tokens, transform requests or responses, handle errors globally, or add logging to HTTP calls. The examples show the new HttpInterceptorFn pattern with inject() for dependencies and the provideHttpClient setup with withInterceptors. Order matters when chaining multiple interceptors, and there's a handy HttpContext pattern for per-request flags like cache control. It's focused on Angular 21 conventions, so if you're still on older versions with class-based interceptors, the patterns here won't directly apply.
- skills.sh installs
- 184
- GitHub stars
- 7
- last updated
- Aug 21, 2026
Install
$ npx -y skills add oguzhan18/angular-ecosystem-skills --skill angular-interceptors --agent claude-codeInstalls into .claude/skills of the current project.
Files
Angular HTTP Interceptors
Version: Angular 21 (2025) Tags: HTTP, Interceptors, Auth, Middleware
References: Interceptors Guide • API
API Changes
This section documents recent version-specific API changes.
-
NEW: Functional interceptors — Use
HttpInterceptorFninstead of class-based -
NEW: provideHttpClient with withInterceptors — Modern interceptor setup
-
NEW: HttpContext — Per-request metadata with HttpContextToken
-
DEPRECATED: Class-based HttpInterceptor — Migrate to functional
Best Practices
- Create functional interceptor
export const authInterceptor: HttpInterceptorFn = (req, next) => {
const authService = inject(AuthService);
const token = authService.getToken();
if (token) {
const authReq = req.clone({
setHeaders: { Authorization: `Bearer ${token}` }
});
return next(authReq);
}
return next(req);
};
- Register interceptors
export const appConfig: ApplicationConfig = {
providers: [
provideHttpClient(
withInterceptors([authInterceptor, logInterceptor])
)
]
};
Sponsors
Details
- Repository
- github.com/oguzhan18/angular-ecosystem-skills
- Categories
- Frontend Development, Backend & APIs, Debugging
- First seen
- Jun 3, 2026
More from oguzhan18/angular-ecosystem-skills
All 45- Angular Schematics184
- Angular Components182
- Angular Destroyref182
- Angular Forms182
- Angular Pipes180
- Angular Resolvers179
- Angular Deferrable178
- Angular Resource178
- Angular Signals178
- Angular Signals Forms178
- Angular Reactive177
- Angular Directives176
- Angular Lifecycle176
- Angular Di175
- Angular Viewchild174
- Angular Cypress172
- Angular Router172
- Angular Control Flow170
- Angular Zoneless170
- Nx170
- Angular Signals Http169
- Angular Ssr168
- Angular Injector165
- Angular Query160