Skip to content

Interface: RouteGuardOptions ​

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

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

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/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.-packages/tanstack-start/src/server.ts:77
onForbidden?GuardHandlerCalled when the subject lacks access. Default: a 403 JSON Response.GuardHandlers.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.GuardHandlers.onUnauthenticatedpackages/tanstack-start/src/server.ts:64

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