Enforce RBAC permissions in your application’s frontend using the Stytch Next.js SDK
import { useStytchIsAuthorized } from '@stytch/next/b2b'; const DocumentActions = () => { const { isAuthorized, isInitialized } = useStytchIsAuthorized('documents', 'edit'); if (!isInitialized) { return <p>Loading...</p>; } // 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> ); };