BETTER-AUTH. UI
API Reference

AuthMutators

Reference for authentication mutation functions like updating profiles and managing sessions.

The AuthMutators interface defines mutation functions for updating authentication state, such as updating the user, removing members, and more.

Reference

PropTypeDefault
unlinkAccount
MutateFn<{ providerId: string; accountId?: string | undefined; }>
-
updateUser
MutateFn<Record<string, unknown>>
-
updateOrganization
MutateFn<{ organizationId: string; data: Record<string, unknown>; }>
-
setActiveSession
MutateFn<{ sessionToken: string; }>
-
revokeSession
MutateFn<{ token: string; }>
-
revokeDeviceSession
MutateFn<{ sessionToken: string; }>
-
deletePasskey
MutateFn<{ id: string; }>
-
deleteApiKey
MutateFn<{ keyId: string; }>
-

Usage

Mutators are accessed through the AuthUIContext. They provide a thin wrapper around better-auth client methods to ensure UI consistency and cache updates.

import { useContext } from "react";
import { AuthUIContext } from "better-auth-ui";

export function ProfileForm() {
  const { mutators } = useContext(AuthUIContext);
  const { updateMemberRole } = mutators;

  const handleRoleUpdate = async () => {
    await updateMemberRole({
      memberId: "...",
      role: "admin",
      organizationId: "...",
    });
  };

  return <button onClick={handleRoleUpdate}>Promote to Admin</button>;
}

On this page