Hooks
useDynamicScopes
If you want to prevent users from reaching specific parts of your app you can use this hook to check if user has specific scope set using our Access List scopes or NFT/Token gating.
How it works?
The scopes are send as a standard JWT scopes field. Using this hook you can easily check if user has access to a specific scope or an array of scopes connected by logical operators like: AND
, OR
.
Hook return values
Name | Type | Description |
---|---|---|
userScopes | string[] | All scopes returned in JWT for specific user |
userHasScopes | (scopes: string[] | string, logicOperator?: ‘AND’ | ‘OR’) => boolean | Function used to check if logged user has specific scope or list of scopes connected by logicOperator. By default the logicOperator is OR |
Limitations
Combinations of AND & OR are not supported. You can only use one logic operator at a time. Let us know in slack if this is something you need!
Examples
-
Check if user has
'signing'
scopeTypeScript -
Check if user has
'signing'
and'creating'
scopesTypeScript -
Check if user has
'signing'
or'creating'
scopesTypeScript
Was this page helpful?