Skip to main content

User Groups

Organize users with groups for role-based access control.


What are Groups?​

Groups allow you to:

  • Organize users by role or permission level
  • Implement role-based access control (RBAC)
  • Easily manage permissions for multiple users

Example Groups​

GroupDescription
adminsFull administrative access
moderatorsContent moderation access
premiumPremium subscription users
beta-testersBeta feature access

πŸ‘‰ Manage groups in the Dashboard: Dashboard β†’ Groups


Dashboard Only

Group management (create, edit, delete, assign users) is performed exclusively through the SyAuth Dashboard. There is no public API for group management.

To manage groups, go to syauth.com/dashboard β†’ Groups.

Checking User Groups​

User groups are included in the user object after authentication.

const { user } = useSyAuth();

// Check if user is in a group
const isAdmin = user?.groups?.includes('admins');
const isPremium = user?.groups?.includes('premium');

if (isAdmin) {
// Show admin features
}

RBAC Component:

// components/RequireGroup.tsx
'use client';

import { useSyAuth } from '@syauth/nextjs';

export function RequireGroup({ group, children, fallback }) {
const { user, isAuthenticated } = useSyAuth();

if (!isAuthenticated || !user?.groups?.includes(group)) {
return fallback || null;
}

return <>{children}</>;
}

Group Properties​

PropertyTypeDescription
idUUIDUnique identifier
namestringGroup name (unique)
descriptionstringOptional description
created_atdatetimeCreation timestamp

Best Practices​

PracticeDescription
Use descriptive namescontent-moderators vs cm
Keep groups focusedOne purpose per group
Document group purposesMaintain documentation
Regular auditsReview group memberships periodically

Next Steps​