Skip to content

Type Alias: Guard<N, O, A, R> ​

ts
type Guard<N, O, A, R> = <X>(args, ...rest) => Promise<R>;

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

A guard typed with the names N it accepts and its options O: (args, ...names, options?). It resolves to the subject (R) when the check passes, and throws a Response (401, 403 or a redirect) when it does not.

Type Parameters ​

Type ParameterDefault type
N extends string-
O-
A extends RouteArgsRouteArgs
RSubjectRbac

Type Parameters ​

Type Parameter
X extends readonly (GuardNames | O)[]

Parameters ​

ParameterType
argsA
...restX & RequirementArgs<X, N, O>

Returns ​

Promise<R>

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