Skip to content

Commit 03e46ef

Browse files
committed
chore: add jsdoc to type
1 parent 52bb9b3 commit 03e46ef

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

packages/types/src/protect.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,29 @@ import type { OrganizationCustomPermissionKey, OrganizationCustomRoleKey } from
22
import type { CheckAuthorizationWithCustomPermissions } from './session';
33
import type { Autocomplete } from './utils';
44

5+
/**
6+
* Props for the `<Protect />` component, which restricts access to its children based on authentication and authorization.
7+
*
8+
* Use `ProtectProps` to specify the required role, permission, feature, or plan for access.
9+
*
10+
* @example
11+
* ```tsx
12+
* // Require a specific permission
13+
* <Protect permission="a_permission_key" />
14+
*
15+
* // Require a specific role
16+
* <Protect role="a_role_key" />
17+
*
18+
* // Use a custom condition callback
19+
* <Protect condition={(has) => has({ permission: "a_permission_key" })} />
20+
*
21+
* // Require a specific feature
22+
* <Protect feature="a_feature_key" />
23+
*
24+
* // Require a specific plan
25+
* <Protect plan=a_plan_key" />
26+
* ```
27+
*/
528
export type ProtectProps =
629
| {
730
condition?: never;

0 commit comments

Comments
 (0)