Admin Panel
The admin panel gives you a bird's-eye view of your SaaS. Track users, subscriptions, revenue metrics, and manage accounts — all from /admin.
Access Control
By default, admin access is restricted by email domain. Edit the check in src/app/(app)/admin/page.tsx:
// Simple domain check (replace with your domain)
if (!session.user.email.endsWith("@yourdomain.com")) {
redirect("/dashboard")
}
For production, you might want a role-based check:
const ADMIN_EMAILS = ["you@example.com", "cofounder@example.com"]
if (!ADMIN_EMAILS.includes(session.user.email)) {
redirect("/dashboard")
}
Dashboard Metrics
The admin dashboard shows four key stats:
| Metric | What It Measures |
|---|---|
| Total Users | All registered accounts |
| Active Subscriptions | Subscriptions with status "active" |
| New Users Today | Signups in the last 24 hours |
| Conversion Rate | Active subs / total users × 100 |
Admin Functions
All admin functions are in src/lib/admin/index.ts:
Get Stats
import { getAdminStats } from "@/lib/admin"
const stats = await getAdminStats()
// { totalUsers: 142, activeSubscriptions: 38, newUsersToday: 5, conversionRate: 26.7 }
List Users (Paginated)
import { getAdminUsers } from "@/lib/admin"
const { users, total } = await getAdminUsers(page, limit)
// Each user includes their subscription info
Get Single User
import { getAdminUser } from "@/lib/admin"
const user = await getAdminUser(userId)
// { ...user, subscription: { status, plan, ... } }
Delete User
import { deleteAdminUser } from "@/lib/admin"
await deleteAdminUser(userId)
// Cascade deletes sessions, accounts, subscriptions
List Subscriptions
import { getAdminSubscriptions } from "@/lib/admin"
const { subscriptions, total } = await getAdminSubscriptions(page, limit)
// Each subscription includes the user info
Pre-Built Pages
- •
/admin— Stats grid + quick links - •
/admin/users— Paginated user table - •
/admin/subscriptions— Subscription management
Extending the Admin
Add new admin pages by creating files in src/app/(app)/admin/:
// src/app/(app)/admin/analytics/page.tsx
export default async function AdminAnalytics() {
// Your custom admin page
return (
<div>
<h1>Analytics</h1>
{/* Revenue charts, user growth, etc. */}
</div>
)
}
Pro Tier Only
The admin panel is available on Pro and Bundle tiers. Starter projects have the admin directory excluded during scaffolding.
Next Steps
- •CLI Reference — The goon CLI in detail
- •Deployment — Take your SaaS to production