Simple API
Intuitive, composable middleware pattern that's easy to understand and use
Route and HTTP request protection through a composable middleware pattern
Install the library:
npm install ngxsmk-gatekeeperUse in your Angular app:
import { provideGatekeeper, gatekeeperGuard } from 'ngxsmk-gatekeeper';
import { createAuthMiddleware } from 'ngxsmk-gatekeeper';
export const appConfig: ApplicationConfig = {
providers: [
provideRouter(routes),
provideHttpClient(),
provideGatekeeper({
middlewares: [createAuthMiddleware()],
onFail: '/login',
}),
],
};Protect your routes:
const routes: Routes = [
{
path: 'dashboard',
component: DashboardComponent,
canActivate: [gatekeeperGuard],
},
];@angular/build@22, ng-packagr@22, and TypeScript 6.0. Tested across Angular 17-22.ngxsmk-gatekeeper/testing secondary entry point for tree-shakeable, test-only imports.next Option - createCacheMiddleware can wrap a downstream middleware and cache its allow/deny result (see cacheOnlySuccess).Angular applications often need to protect routes and HTTP requests based on authentication, authorization, feature flags, or other business logic. ngxsmk-gatekeeper provides:
ngxsmk-gatekeeper is 100% open source and completely free to use. All features are available without any restrictions: