# Rolebook docs > An authorization library for TypeScript that supports RBAC, ABAC, field-level permissions, and resource sharing. Covers the Rolebook engine and its first-party packages. - **Get started** - [Introduction](/docs): Permissions and resource sharing for TypeScript: roles, conditions, field rules, teams, invitations, webhooks, and audit logs. - [Installation](/docs/installation): Packages, entry points, runtimes, and peer dependencies. - [Quick start](/docs/getting-started): Define a policy, bind a subject, check a permission. - [Choose how decisions run](/docs/choosing): The embedded engine, the Sharing module and its HTTP API, the decision service, and signed offline snapshots, and when to use each. - **Concepts** - [Policies](/docs/policies): Resources and actions, rules, wildcards, versions, and the policy lifecycle. - [Roles and scopes](/docs/roles-and-scopes): Where a role lives, what its rules may target, and how inheritance works. - [Subjects, principals, and assignments](/docs/subjects-and-assignments): Who is asking, which groups they act through, and which scoped roles apply. - [Trusted resources and ancestry](/docs/trusted-resources): Resource snapshots with ancestry, and what they do and do not prove. - [Conditions, facts, and fields](/docs/conditions-and-fields): Constrain a rule by facts about the subject, resource, and request, and by field paths. - [Decisions, enforce, and explain](/docs/decisions): Decision codes, check versus enforce, explanation traces, and fault reporting. - [Evaluation order and deny precedence](/docs/evaluation): Exactly how Rolebook turns a binding and a request into a decision. - [Limits](/docs/limits): The hard bounds that keep policy compilation and evaluation finite. - **Recipes** - [ACL recipe](/docs/recipes/acl): Scoped roles, explicit deny, revocation, and resource membership commands. - [HTTP authorization](/docs/recipes/http-authorization): Protect application routes with the Hono adapter without revealing whether a document exists. - **Guides** - [Multi-tenant setup](/docs/multi-tenant): Model tenants, load bindings and resources per tenant, and keep every input authoritative. - [Add resource sharing](/docs/adding-sharing): An end-to-end guide to sharing one resource type with owners, members, and invitations. - [Hono middleware](/docs/hono): Guard Hono routes with a binding and a trusted resource per request. - [Testing your integration](/docs/testing): Table-driven policy tests, decision suites as JSON, explain-based debugging, sharing with the in-memory adapter, the adapter contracts, and testing providers for the decision service and offline snapshots. - [Fact schemas](/docs/fact-schemas): Declare the facts your policy reads, catch mistyped fact paths and operand types before deployment, and check request facts before binding. - [Migrations and upgrades](/docs/migrations): Moving to Rolebook 4, adopting sharing one resource type at a time, and upgrading the sharing packages. - [Security model](/docs/security-model): What Rolebook guarantees, and what your application must establish. - [Connect to Rolebook Console](/docs/connect-to-rolebook-console): The connector that lets Rolebook Console, the hosted console, change sharing in your app, through your own Sharing instance and database. - [What happens when](/docs/what-happens-when): Scenario by scenario, what Rolebook does when an answer is lost, two writers collide, a receiver is down or the console and your application disagree. - **AI and agents** - [Docs for agents and LLMs](/docs/agents): Give a coding agent or an LLM tool these docs as Markdown, and teach it Rolebook with the skills bundle. - Skills - [Skills](/docs/agents/skills): Skills that teach your coding agent to add Rolebook authorization and sharing to an app the right way. - [Set up Rolebook](/docs/agents/skills/rolebook-setup): The rolebook-setup agent skill. - [Add sharing](/docs/agents/skills/rolebook-add-sharing): The rolebook-add-sharing agent skill. - [Add the screens](/docs/agents/skills/rolebook-add-screens): The rolebook-add-screens agent skill. - [Write roles](/docs/agents/skills/rolebook-write-roles): The rolebook-write-roles agent skill. - [Debug a no](/docs/agents/skills/rolebook-debug-denial): The rolebook-debug-denial agent skill. - [Review before launch](/docs/agents/skills/rolebook-launch-review): The rolebook-launch-review agent skill. - [Mount the API](/docs/agents/skills/rolebook-mount-api): The rolebook-mount-api agent skill. - [Add custom roles](/docs/agents/skills/rolebook-custom-roles): The rolebook-custom-roles agent skill. - [Run sharing in production](/docs/agents/skills/rolebook-operate-sharing): The rolebook-operate-sharing agent skill. - [Write a storage adapter](/docs/agents/skills/rolebook-write-adapter): The rolebook-write-adapter agent skill. - [MCP server](/docs/agents/mcp): rolebook mcp: a Model Context Protocol server that runs next to your own Rolebook server, so an agent can look up and explain access and propose changes you confirm. - **API reference** - Core API - [rolebook](/docs/api): Every export of the rolebook package, with its signature and behaviour. - [rolebook/middleware/hono](/docs/api/hono): The exports of the optional Hono middleware entry point. - [rolebook/middleware/express](/docs/api/express): The exports of the optional Express middleware entry point. - [rolebook/middleware/fastify](/docs/api/fastify): The exports of the optional Fastify middleware entry point. - [rolebook/authoring](/docs/api/authoring): The exports of the optional authoring entry point - fact schemas, policy diagnostics, and fact validation. - **Packages** - @rolebook/sharing - [Resource sharing](/docs/sharing): @rolebook/sharing: tenant-scoped membership, ownership, invitations, and audit, decided by Rolebook. - [Define and create](/docs/sharing/setup): The policy roles sharing needs, defineSharing, createSharing options, and secret keys. - [Commands](/docs/sharing/commands): execute() and its seven commands, tenant.governance, idempotency, conflict retries, expiring memberships, and result codes. - [Delegation and denials](/docs/sharing/delegation): The delegation ceiling, deny-carrying roles on groups, owner recovery, and how denials hide resource existence. - [Inherited access](/docs/sharing/inheritance): Let documents inherit access from their folder chain, with PostgreSQL or SQLite, opt-in per type and bounded. - [Authorize, permissions, and inspection](/docs/sharing/reads): authorize(), permissions(), describeAccess(), and auditHistory(). - [Current-state inspection](/docs/sharing/inspection): explain(): why one subject is or is not allowed an action right now, for privileged inspectors, rate limited and audited. - [Listing accessible resources](/docs/sharing/listing): listAccessible() and listAccess(), consistent pages and what they require, sealed cursors, candidate pre-filters, and listing errors. - [Named authorized queries](/docs/sharing/authorized-queries): Registered, filtered and sorted queries over your own resource table that return only the keys the actor is allowed, checked in one database snapshot. - [Policy versions and custom roles](/docs/sharing/versioned): createVersionedSharing(), the policy store, publishing, staleness bounds, impact previews, and tenant custom roles. - [Storage and identity adapters](/docs/sharing/adapters): The SharingAdapter and TenantIdentityAdapter contracts, the workspace identity factory, and the in-memory adapter. - [Bounded outbox delivery](/docs/sharing/outbox-delivery): Run one bounded delivery pass with explicit sink outcomes and fenced settlement. - [Access-change webhooks](/docs/sharing/webhooks): Notify other systems, with signed HTTP requests, when access to a resource changes. - [Retention and pruning](/docs/sharing/retention): Pruning settled idempotency records and invitations with pruneSettledRecords(). - [@rolebook/sharing API](/docs/sharing/api): Every export of @rolebook/sharing, with its signature and behaviour. - [@rolebook/sharing/checkpoints](/docs/sharing/checkpoints): The exports of the opt-in consistency checkpoint entry point of @rolebook/sharing. - @rolebook/sharing-postgres - [PostgreSQL adapter](/docs/sharing-postgres): @rolebook/sharing-postgres: an ORM-neutral PostgreSQL storage adapter for sharing. - [PostgreSQL migrations](/docs/sharing-postgres/migrations): Generating, applying, upgrading, and rolling back the sharing and policy-store schema on PostgreSQL. - [PostgreSQL fences and transactions](/docs/sharing-postgres/fences): Eligibility, email-recipient, workspace-role, team, and policy fences, and SERIALIZABLE retries. - [PostgreSQL resource lifecycle](/docs/sharing-postgres/lifecycle): Initializing owners, and deleting or moving resources atomically with their sharing state. - [Protected application updates](/docs/sharing-postgres/protected-updates): Authorize and commit one PostgreSQL resource/action update with a durable receipt. - [Managed field updates](/docs/sharing-postgres/managed-updates): Apply a declared patch with field authorization before and after a PostgreSQL update. - [Managed deletion](/docs/sharing-postgres/managed-deletion): Delete one authorized resource and its live sharing state in one local transaction. - [Managed same-tenant moves](/docs/sharing-postgres/managed-moves): Reparent one leaf resource using SQL-authoritative parent permissions in one transaction. - [@rolebook/sharing-postgres API](/docs/sharing-postgres/api): Every export of @rolebook/sharing-postgres, with its signature and behaviour. - @rolebook/sharing-sqlite - [SQLite adapter](/docs/sharing-sqlite): @rolebook/sharing-sqlite: a driver-neutral SQLite storage adapter for local-first, edge, and desktop apps. - [SQLite migrations](/docs/sharing-sqlite/migrations): The migration runner, drift policy, rollback, upgrades, and policy-store tables on SQLite. - [SQLite concurrency, fences, and lifecycle](/docs/sharing-sqlite/operations): BEGIN IMMEDIATE, busy retries, identity fences, teams, initialization, deletes, and moves on SQLite. - [Protected and managed updates](/docs/sharing-sqlite/protected-updates): Local SQLite authorization, application updates and durable recovery in one owned transaction. - [Managed deletion](/docs/sharing-sqlite/managed-deletion): Delete one authorized resource and its live sharing state in one local transaction. - [Managed same-tenant moves](/docs/sharing-sqlite/managed-moves): Reparent one leaf resource using SQL-authoritative parent permissions in one transaction. - [@rolebook/sharing-sqlite API](/docs/sharing-sqlite/api): Every export of @rolebook/sharing-sqlite and its /bun, /bun-query and /libsql entry points. - @rolebook/teams - [Teams](/docs/teams): @rolebook/teams: flat, bounded team principals for sharing, with directories, an identity wrapper, and fences. - [@rolebook/teams API](/docs/teams/api): Every export of @rolebook/teams and its /sql, /better-auth, and /sqlite entry points. - [Better Auth](/docs/sharing-better-auth): @rolebook/sharing-better-auth: Better Auth organizations as the source of users and workspace membership. - [Better Auth plugin](/docs/better-auth): @rolebook/better-auth: Rolebook Sharing as a Better Auth 1.7.14 plugin, with a client plugin and React bindings. - [Clerk](/docs/sharing-clerk): @rolebook/sharing-clerk: Clerk organizations as the source of users and organization membership. - [WorkOS](/docs/sharing-workos): @rolebook/sharing-workos: WorkOS User Management as the source of users and membership, plus Directory Sync groups. - [Sharing testkit](/docs/sharing-testkit): @rolebook/sharing-testkit: the security contract every sharing adapter must pass. - HTTP API - [HTTP API](/docs/http-api): Serve the sharing operations over HTTP with @rolebook/server, and call them from a browser with @rolebook/client. - [@rolebook/server](/docs/http-api/server): A mountable fetch handler for the sharing HTTP API, with Hono and Next.js adapters. - [@rolebook/client](/docs/http-api/client): A typed fetch client for the sharing HTTP API. - [@rolebook/http](/docs/http-api/http): The wire contract of the sharing HTTP API: operations, codecs, schemas, and OpenAPI. - [React components](/docs/react): @rolebook/react: accessible sharing screens and headless state for the Rolebook Sharing HTTP API. - [The rolebook command](/docs/cli): @rolebook/cli: set up Rolebook, check a setup, explain decisions, read and change access on your own server, and compare policies. - [Migrating from Casbin and role tables](/docs/migrate): @rolebook/migrate: a strict Casbin-subset checker, import planners, plan diffs, and a read-only shadow comparison. - [The P1 input profile](/docs/scalars-p1): @rolebook/scalars-p1: bounded raw JSON admission shared by the decision service and offline snapshots. - [Decision service](/docs/decision-service): @rolebook/decision-service: authenticated single and batch Core checks through a Fetch handler. - [Offline check snapshots](/docs/offline): @rolebook/offline: signed exact-check snapshots with explicit trust, freshness and rollback boundaries. - [Access guardrails](/docs/guardrails): @rolebook/guardrails: organization-wide policies that block, hold for approval, or notify on top of role decisions. ## Comparison guides - [Rolebook vs Casbin, OpenFGA, Permit and SpiceDB](https://rolebook.dev/compare): Rolebook is a TypeScript authorization library that decides inside your application, from facts your server has already loaded. Pick the need closest to yours. ([Markdown](https://rolebook.dev/compare.md)) - [Rolebook vs Casbin: check a migration before you switch](https://rolebook.dev/compare/casbin): Rolebook fits when you run a Casbin role model and want to compare both systems on real checks before enforcement changes. ([Markdown](https://rolebook.dev/compare/casbin.md)) - [Rolebook vs OpenFGA: share a resource with a team](https://rolebook.dev/compare/openfga): Rolebook fits when your teams live in Better Auth or your own tables and sharing with a team should be one command in your application. ([Markdown](https://rolebook.dev/compare/openfga.md)) - [Rolebook vs Permit: field-level checks in your request](https://rolebook.dev/compare/permit): Rolebook fits when a TypeScript request handler should decide field by field, in process, from facts your server has already loaded. ([Markdown](https://rolebook.dev/compare/permit.md)) - [Rolebook vs SpiceDB: authorize and update in one transaction](https://rolebook.dev/compare/spicedb): Rolebook fits when your application updates a row in PostgreSQL and the permission check should commit or roll back with that update. ([Markdown](https://rolebook.dev/compare/spicedb.md))