π Introducing ngx-smart-permissions β Lightweight Role & Permission Handling for Angular Apps
Managing access control in Angular apps shouldn't be complicated. That's why I built:
π ngx-smart-permissions
A lightweight, smart Angular library that lets you control access using roles and permissions, with clean APIs and full support for Angular 17 & 18.
π Why ngx-smart-permissions?
Whether you're building an admin dashboard, an enterprise portal, or a CMS β managing permissions should be simple, declarative, and testable.
This library helps you:
- β Show/hide UI elements based on permissions or roles
- β
Use powerful directives like
*ngxHasPermission,*ngxHasRole - β Protect routes using permission-based guards
- β Enable Super Admin override
- β Handle lazy-loaded modules
- β Work seamlessly with both NgModules and Standalone Components
π§ Installation
npm install ngx-smart-permissions
βοΈ Usage Example
β UI Permission Check
<button *ngxHasPermission="'edit-post'">Edit</button>
β Role-based Check
<div *ngxHasRole="'admin'">Admin Area</div>
π Route Guard Example
{
path: 'dashboard',
canActivate: [permissionGuard],
data: { permission: 'view-dashboard' }
}
π Live Permission Switching
permissionService.switchPermissions(['edit-users', 'view-dashboard'], true, 'admin');
Great for dynamic role switching and testing environments!
π Try it Live
- π GitHub: ngx-smart-permissions
- π» Demo App: ngx-smart-permissions-demo
π¨βπ» About the Author
Hi, I'm Rami Shaikha, a passionate Angular developer and OSS contributor.
Would love your feedback, stars β, or even contributions if this library helps you.
β€οΈ Support & Feedback
If you're using Angular and want clean, scalable access control β give it a try!
Open to suggestions, improvements, or just a π in the comments.
π· Tags
#angular #typescript #webdev #opensource #frontend #authorization #accesscontrol
Top comments (0)