Skip to content

Interface: RouteGuardOptions<A> ​

Defined in: packages/react-router/src/server.ts:90

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

Extends ​

Extended by ​

Type Parameters ​

Type ParameterDefault type
A extends RouteArgsRouteArgs

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/react-router/src/server.ts:86
forbiddenRedirect?string | ((args) => string)Redirect users without access here (302) instead of the 403.GuardHandlers.forbiddenRedirectpackages/react-router/src/server.ts:81
guard?stringCheck in this guard instead of the server's (subject.withScope({ guard })), like spatie's role:admin,api.-packages/react-router/src/server.ts:92
onForbidden?GuardHandler<A>Called when the subject lacks access. Wins over forbiddenRedirect. Default: a 403 JSON Response.GuardHandlers.onForbiddenpackages/react-router/src/server.ts:74
onUnauthenticated?GuardHandler<A>Called when there is no subject. Wins over unauthenticatedRedirect. Default: a 401 JSON Response.GuardHandlers.onUnauthenticatedpackages/react-router/src/server.ts:72
unauthenticatedRedirect?string | ((args) => string)Redirect guests here (302) instead of the 401. Handy for page loaders: '/login'. A function gets the args, e.g. to keep the page: ({ request }) => /login?redirectTo=${new URL(request.url).pathname}``.GuardHandlers.unauthenticatedRedirectpackages/react-router/src/server.ts:79

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