@vocoweb/admin
v1.1.0
Published
Production-ready super admin panel for B2B SaaS founders
Maintainers
Readme
@vocoweb/admin
Production-ready super admin panel for B2B SaaS founders.
Overview
@vocoweb/admin is the "God Mode" module that every founder needs. Automatically inject a /admin route into your app with user impersonation, organization management, and error monitoring—without writing a single line of admin UI code.
Key Features:
- 🎭 User Impersonation - Login as any user for support
- 👥 User Management - View and manage all users
- 🏢 Organization View - See all teams and members
- 💳 Manual Upgrades - Comp users or upgrade plans
- 📊 Error Logs - View application error logs
- 🔒 Secure - Admin-only middleware protection
Installation
npm install @vocoweb/adminQuick Start
Middleware Setup
// middleware.ts
import { createAdminMiddleware } from '@vocoweb/admin';
export const middleware = createAdminMiddleware({
// Only allow specific admin emails
adminEmails: ['[email protected]', '[email protected]'],
});
export const config = {
matcher: ['/admin/:path*'],
};Admin Page
// app/admin/page.tsx
import { VocoAdminPanel } from '@vocoweb/admin/react';
export default function AdminPage() {
return <VocoAdminPanel />;
}That's it! You now have a full admin panel at /admin.
API Reference
Server Methods
impersonateUser(adminId, targetUserId)- Login as any usergetAllOrganizations()- View all organizationsupgradeUserPlan(userId, plan)- Manually upgrade usergetErrorLogs(filters)- Fetch error logsisAdmin(userId)- Check if user is admin
React Components
<VocoAdminPanel />- Complete admin dashboard<VocoUserList />- User list with search and impersonation<VocoOrganizationTable />- Organization management table
Features
User Impersonation
import { admin } from '@vocoweb/admin';
// Server action
export async function impersonateUser(targetUserId: string) {
const currentUser = await auth.requireUser();
await admin.isAdmin(currentUser.id);
// Generate impersonation token
const token = await admin.impersonateUser(currentUser.id, targetUserId);
// User is now logged in as targetUserId
return { token };
}Manual Plan Upgrade
// Comp a user to Pro plan
await admin.upgradeUserPlan('user_123', 'pro');View All Organizations
const orgs = await admin.getAllOrganizations();
// Returns: [{ id, name, owner, memberCount, plan }]Environment Variables
# Supabase (Required)
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
# Admin Configuration
[email protected],[email protected]
# Stripe (For plan management)
STRIPE_SECRET_KEY=sk_...Security
⚠️ CRITICAL: Only expose /admin routes to verified admin users.
The middleware automatically checks:
- User is authenticated
- User email is in
ADMIN_EMAILSenv variable - User has admin role in database (if using RBAC)
Admin UI Preview
The <VocoAdminPanel /> includes:
- User search and filtering
- Organization browser
- Impersonation button (login as user)
- Plan upgrade controls
- Error log viewer
- Activity timeline
License
MIT © VocoWeb
Support
- Email: [email protected]
- Documentation: GitHub Wiki
Built with care by VocoWeb
