/
Contact usSee pricingStart building
Node
​

    About Stytch

    Introduction
    Integration Approaches
      Full-stack overview
      Frontend (pre-built UI)
      Frontend (headless)
      Backend
    Migrations
      Migration overview
      Migrating users statically
      Migrating users dynamically
      Additional migration considerations
      Zero-downtime deployment
      Defining external IDs for users
      Migrating from Stytch Consumer to B2B
      Exporting from Stytch
    Custom Domains
      Overview

    Authentication

    DFP Protected Auth
      Overview
      Setting up DFP Protected Auth
      Handling challenges
    Magic Links
    • Email Magic Links

      • Getting started with the API
        Getting started with the SDK
        Replacing your password reset flow
        Building an invite user flow
        Add magic links to an existing auth flow
        Adding PKCE to a Magic Link flow
        Magic Link redirect routing
    • Embeddable Magic Links

      • Getting started with the API
    MFA
      Overview
      Backend integration
      Frontend integration
      Remembered device flow
    Mobile Biometrics
      Overview
    M2M Authentication
      Authenticate an M2M Client
      Rotate client secrets
      Import M2M Clients from Auth0
    OAuth
    • Identity providers

      • Overview
        Provider setup
      Getting started with the API (Google)
      Add Google One Tap via the SDK
      Email address behavior
      Adding PKCE to an OAuth flow
    Connected AppsBeta
      Setting up Connected Apps
      Client types
    • Integration Guides

      • Integrate with AI agents
        Integrate with MCP servers deployed on Cloudflare
        Integrate with MCP servers on Vercel
        Integrate with CLI Apps
    • Resources

      • About Remote MCP Servers
        Consent Management
    Passcodes
      Getting started with the API
      Getting started with the SDK
    • Toll fraud

      • What is SMS toll fraud?
        How you can prevent toll fraud
      Unsupported countries
    Passkeys & WebAuthn
    • Passkeys

      • Passkeys overview
        Set up Passkeys with the frontend SDK
    • WebAuthn

      • Getting started with the API
        Getting started with the SDK
    Passwords
      Getting started with the API
      Getting started with the SDK
      Password strength policy
    • Email verification

      • Overview
        Email verification before password creation
        Email verification after password creation
    Sessions
      How to use sessions
      Backend integrations
      Frontend integrations
      Custom claims
      Custom claim templates
      Session tokens vs JWTs
      How to use Stytch JWTs
    TOTP
      Getting started with the API
      Getting started with the SDK
    Web3
      Getting started with the API
      Getting started with the SDK
    Trusted Auth Tokens
      How to use Trusted Auth Tokens

    RBAC

    Resources
      Overview
      Role assignment
    Integration Guides
      Start here
      Backend integration
      Headless frontend integration
      (Legacy) Implement RBAC with metadata

    3rd Party Integrations

    Planetscale
    Supabase
    Feathery
    Unit

    Testing

    E2E testing
    Sandbox values
Get support on SlackVisit our developer forum

Contact us

Consumer Authentication

/

Guides

/

RBAC

/

Integration Guides

/

Headless frontend integration

Headless Integration of RBAC

While it is important to always have server-side authentication and authorization checks, Stytch's frontend SDKs offer:

  • Built-in RBAC protections for Stytch methods
  • Client side RBAC policy evaluations to minimize unnecessary, unauthorized requests to the server
  • Methods for viewing all permissions for the currently logged in user, to make it easy to conditionally render UI elements

Client Side Authorization Checks

While there should always be server-side authorization checks occurring (whether on Stytch's servers, when calling Stytch methods, or on your own servers for application specific actions) Stytch's SDKs provide a way to do a pre-emptive client-side authorization check to avoid any unnecessary API requests or ensure the user isn't about to enter a flow they cannot complete.

For example, in vanilla Javascript you would perform a check like this before allowing a user to edit a document:

<button disabled={!isAuthorized} onClick={editDocument}>Edit</button>

<script>
    import { StytchHeadlessClient } from '@stytch/vanilla-js/headless';
    const stytch = new StytchHeadlessClient('STYTCH_PUBLIC_TOKEN');
    const isAuthorized = stytch.rbac.isAuthorizedSync('documents', 'update');
    const editDocument = () => {
    //...
    };
</script>

See the SDK reference docs for more details on differences between frameworks.

Conditional Rendering of Authorized Actions

In order to conditionally render parts of your UI based on the logged-in User's permissions (such as showing an edit button as enabled or disabled) you can use the allPermissions() method, or in React the HOC (higher-order component) of withStytchPermissions.

For example, using our React SDK you would do the following:

import { withStytchPermissions } from '@stytch/react';

const MyComponent = (props) => {
  const canEditDocuments = props.stytchPermissions['document']['edit'];

  return (
    <>
      <button disabled={!canEditDocuments} onClick={editDocument}>Edit Document</button>;
    </>
  )
}

export default withStytchPermissions(MyComponent);

Client Side Authorization Checks

Conditional Rendering of Authorized Actions