CASL limits which resources a user may access using declarative rules shared across frontend, backend, and database layers.
Overview
CASL is an isomorphic JavaScript authorization library written in TypeScript. It expresses what actions a user may take on which resources, scaling from simple capability checks to subject and attribute rules inspired by the cancan pattern.
Abilities are built from actions, subjects, optional conditions, and optional field restrictions. You define rules once, then call can and cannot on an Ability instance to gate UI, services, and queries consistently.
The core package stays small and tree-shakable, with separate integrations for Mongoose, Prisma, React, Vue, and Angular named in the ecosystem table. Rules can be serialized so permissions travel between UI and API or microservices.
Documentation on the project site walks through evolving from claims to actions, RBAC, ABAC, and relationship-aware checks using the same model over time.
Key features
- Declarative ability rules
- RBAC and ABAC support
- Frontend and backend use
- TypeScript-first APIs
- Tree-shakable core package
- Serializable permission rules
- ORM integration packages
- Framework helper packages
Use cases
- Shared UI and API permissions
- Blog and content access control
- Tenant-scoped resource policies
- MongoDB query authorization