Skip to content

Interface: PermissionGuardOptions ​

Defined in: packages/tanstack-start/src/server.ts:80

The options every guard takes as its last argument: the handlers plus guard. They win over the defaults.

Extends ​

Properties ​

PropertyTypeDescriptionInherited fromDefined in
any?booleanPass when the subject has ANY of the permissions (instead of all). Default: false.-packages/tanstack-start/src/server.ts:82
exposeRequirements?booleanInclude the required roles/permissions in the default 403 body (required). Default: false (like spatie's display_permission_in_exception).RouteGuardOptions.exposeRequirementspackages/tanstack-start/src/server.ts:71
guard?stringCheck in this guard instead of the server's (subject.withScope({ guard })), like spatie's role:admin,api.RouteGuardOptions.guardpackages/tanstack-start/src/server.ts:77
onForbidden?GuardHandlerCalled when the subject lacks access. Default: a 403 JSON Response.RouteGuardOptions.onForbiddenpackages/tanstack-start/src/server.ts:66
onUnauthenticated?GuardHandlerCalled when there is no subject. Default: a 401 JSON Response. For a page, return TanStack Router's redirect({ to: '/login' }): a plain 302 Response from a server function is followed by fetch, not the router.RouteGuardOptions.onUnauthenticatedpackages/tanstack-start/src/server.ts:64

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