Skip to content

Interface: RouteGuardOptions ​

Defined in: packages/sveltekit/src/server/guards.ts:78

The options every guard takes as its last argument: the handlers plus guard. A guard's own handlers win over the defaults of createGuards().

Extends ​

Extended by ​

Properties ​

PropertyTypeDescriptionInherited fromDefined in
exposeRequirements?booleanInclude the required roles/permissions in the default 403 body (required). Default: false (like spatie's display_permission_in_exception).GuardHandlers.exposeRequirementspackages/sveltekit/src/server/guards.ts:71
forbiddenRedirect?stringRedirect users without access here (redirect(303, url)) instead of the 403 error.GuardHandlers.forbiddenRedirectpackages/sveltekit/src/server/guards.ts:66
guard?stringCheck in this guard instead of the request's (subject.withScope({ guard })), like spatie's role:admin,api. Default: the guard of rbacHandle().-packages/sveltekit/src/server/guards.ts:83
onForbidden?GuardHandlerCalled when the subject lacks access. Wins over forbiddenRedirect. Default: error(403, { error: 'FORBIDDEN', reason, message }).GuardHandlers.onForbiddenpackages/sveltekit/src/server/guards.ts:62
onUnauthenticated?GuardHandlerCalled when there is no subject (event.locals.rbac is null). Wins over unauthenticatedRedirect. Default: error(401, { error: 'UNAUTHENTICATED', message }).GuardHandlers.onUnauthenticatedpackages/sveltekit/src/server/guards.ts:57
unauthenticatedRedirect?stringRedirect guests here (redirect(303, url)) instead of the 401 error. Handy for page loads: '/login'.GuardHandlers.unauthenticatedRedirectpackages/sveltekit/src/server/guards.ts:64

Released under the MIT License. Inspired by spatie/laravel-permission.