Roles & permissions for Node.js, in 2 minutes.
Simple, type-safe access control for your backend. Works with MySQL, Postgres and MongoDB.
requirePermission(perms, "posts.publish")Role "editor" possesses permission "posts.publish". Route handler executes.
One line to protect a route
Familiar syntax, asynchronous by design, and strict TypeScript types so typos are caught before you deploy.
Everything you need for access control
Simple English, benefit-focused access control designed for modern Node.js backends.
Zero dependencies
Nothing extra in your node_modules.
Type-safe
Autocomplete for your own role and permission names.
Your database
MySQL, MariaDB, Postgres or MongoDB.
Express ready
Protect routes with one line.
One-command setup
npx permly init creates everything.
Fast
Built-in cache, cleared automatically on changes.
Ownership rules
"Users can edit only their own posts" built in.
Safe under load
Tested against concurrent requests.
Built to be trusted in production
Real metrics from the codebase. Every pull request and release is validated across real database instances in automated CI pipelines.
Stop writing permission checks by hand.
Move away from hardcoded role comparisons and duplicate if-statements scattered across your routes.
Less code. One place for all access rules.
From whole modules down to a single button.
Give access to an entire module, one tab, or one action. Show each user only what they're allowed to see, and protect your API with the same rules.
Manager: Wildcard orders.* unlocks the entire Orders module, all its tabs, and every action button.
orders.*orders.list.*orders.refunds.*products.*products.catalog.*products.inventory.*reports.*reports.revenue.*reports.audit.*// Give whole module access with wildcard
await perms.role("manager").givePermission("orders.*");
// Give access to module and specific sub-tabs
await perms.role("support").givePermission("orders.access", "orders.list.*");
// Grant individual user access to one extra tab
await perms.user(42).givePermission("orders.refunds.view");Hierarchical, intuitive wildcards
Permly evaluates wildcards from broad to specific. Assigning orders.* automatically satisfies route guards like orders.refunds.approve. No messy permission arrays or manual sync required.
Works with your existing database
No lock-in. Permly works seamlessly with SQL and NoSQL engines alike, managing its own tables or collections cleanly.
PostgreSQL
Uses JSONB & connection pooling with pg / postgres.js drivers.
MySQL
Supports mysql2 with prepared statements and row-level locking.
MongoDB
Native documents, subdocuments, and index-optimized permission checks.
MariaDB
High concurrency and transaction-isolated role syncing.
Get up and running in 3 steps
From zero to a fully protected Express, Fastify, or standalone Node.js service in under two minutes.
Install the package
Zero external runtime dependencies. Installs in seconds.
Initialize and run migrations
Generates configuration and creates permission tables in your selected database.
Assign roles and protect routes
Guard endpoints with declarative middleware or check user abilities directly.