🛡️ Admin Dashboard
Module ID:
@saas/admin| Version: 1.0.0
User management admin panel gated by 3-tier RBAC (admin-only). Provides user table, role selector, and delete-user action.
Installation
npx shadcn@latest add @saas/adminDependencies
@saas/auth@saas/rbac
Routes
(dashboard)/admin/page.tsx
Server Actions
actions/admin.ts
Database Tables
users
Post-Install Steps
Step 1 (manual): Verify the role enum migration is present. The users table must have a 'role' pgEnum column with values ['admin', 'editor', 'viewer']. Run: pnpm db:generate && pnpm db:migrate if the column is missing.
Step 2 (manual): Wire the admin nav link in your sidebar. Add a conditional link to '/dashboard/admin' visible only when isAdmin(session.user.role) is true. Import isAdmin from '@/lib/is-admin'.
Live Demo
Configure your deployed Next.js app URL via the VITEPRESS_DEMO_BASE environment variable, then rebuild to enable live iframe embeds.
API Demonstration
Server Actions note: Server Actions (
"use server") are not callable cross-origin. Use the "Try in Live App" link above to interact with them.