Each Member Session will be granted specific roles, which grants them permission to take specific actions on specific Resources. To check if a Member has permission to take an action on a Resource, use the .
import { useStytchIsAuthorized } from '@stytch/react/b2b';const DocumentActions = () => { const { isAuthorized } = useStytchIsAuthorized('documents', 'edit'); // Check permissions both before taking actions const editDocument = () => { if (!isAuthorized) { throw new Error('You do not have permission to edit documents'); } proceedWithEdit(); }; // And to hide or disable UI elements return ( <div> <button disabled={!isAuthorized} onClick={editDocument}>Edit Document</button> </div> );};
⌘I
Assistant
Responses are generated using AI and may contain mistakes.