Interface: PermissionGuardOptions<A>
Defined in: packages/react-router/src/server.ts:95
The options every guard takes as its last argument: the handlers plus guard. They win over the defaults.
Extends
Type Parameters
| Type Parameter | Default type |
|---|---|
A extends RouteArgs | RouteArgs |
Properties
| Property | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|
any? | boolean | Pass when the subject has ANY of the permissions (instead of all). Default: false. | - | packages/react-router/src/server.ts:97 |
exposeRequirements? | boolean | Include the required roles/permissions in the default 403 body (required). Default: false (like spatie's display_permission_in_exception). | RouteGuardOptions.exposeRequirements | packages/react-router/src/server.ts:86 |
forbiddenRedirect? | string | ((args) => string) | Redirect users without access here (302) instead of the 403. | RouteGuardOptions.forbiddenRedirect | packages/react-router/src/server.ts:81 |
guard? | string | Check in this guard instead of the server's (subject.withScope({ guard })), like spatie's role:admin,api. | RoleGuardOptions.guard | packages/react-router/src/server.ts:92 |
onForbidden? | GuardHandler<A> | Called when the subject lacks access. Wins over forbiddenRedirect. Default: a 403 JSON Response. | RouteGuardOptions.onForbidden | packages/react-router/src/server.ts:74 |
onUnauthenticated? | GuardHandler<A> | Called when there is no subject. Wins over unauthenticatedRedirect. Default: a 401 JSON Response. | RouteGuardOptions.onUnauthenticated | packages/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}``. | RouteGuardOptions.unauthenticatedRedirect | packages/react-router/src/server.ts:79 |
