Enforce fine-grained authorization in SvelteKit load functions, form actions, and server hooks using Cerbos. Gate access to pages and mutations with policy-based checks on the server side.
Authorize access to page data in server load functions and protect mutations in form actions with a single Cerbos call
Pass user session data, resource attributes, and route parameters from SvelteKit's request event to Cerbos for attribute-based authorization
Use SvelteKit's handle hook to apply blanket authorization checks across routes, keeping access control logic out of individual page components
Building authorization logic inside SvelteKit quickly becomes a maintenance burden. Hard-coded role checks scatter across controllers and middleware, and every permission change requires a code deploy.
Cerbos replaces scattered authorization logic with a single API call. You define fine-grained policies in YAML, and the Cerbos PDP evaluates them at request time using roles, attributes, and any context you provide.
With Cerbos your SvelteKit application stays focused on business logic while authorization policies evolve independently, managed by product or security teams without touching code.
Install the Cerbos JavaScript SDK and call the Cerbos PDP from your SvelteKit server load functions, form actions, or hooks. Authorization runs server-side, so you can enforce access control before data reaches the client.
The most common approach is to call Cerbos in server load functions (+page.server.ts) to gate page data, in form actions to authorize mutations, and in the handle hook (hooks.server.ts) for blanket route protection. Choose the level of granularity that fits your application.
Yes. You can call Cerbos in a layout's server load function and pass the authorization results to all child pages through SvelteKit's data inheritance. This lets you control navigation, show or hide UI elements, and prevent unauthorized access throughout a section of your application.


What is Cerbos?
Cerbos is an end-to-end enterprise authorization software for Zero Trust environments and AI-powered systems. It enforces fine-grained, contextual, and continuous authorization across apps, APIs, AI agents, MCP servers, services, and workloads.
Cerbos consists of an open-source Policy Decision Point, Enforcement Point integrations, and a centrally managed Policy Administration Plane (Cerbos Hub) that coordinates unified policy-based authorization across your architecture. Enforce least privilege & maintain full visibility into access decisions with Cerbos authorization.