Admin
Manage users, orders, and metrics.
Overview
The admin dashboard provides user management, order visibility, and revenue stats.
Access control
Only users with the admin role can access /admin.
Promote a user to admin
UPDATE users SET role = 'admin' WHERE email = 'admin@example.com';Modules
Overview dashboard
Visit /admin to see:
- Total users
- Lifetime users
- Monthly revenue
- Total revenue
Users
Visit /admin/users to:
- Browse all users
- Search by email or name
- View details and access status
- Paginate results
Orders & payments
Visit /admin/orders to:
- Review orders
- Check payment status
- Inspect amounts and timestamps
API reference
Fetch admin stats
// GET /api/admin/stats
const response = await fetch('/api/admin/stats');
const { data } = await response.json();Fetch users
// GET /api/admin/users?page=1&limit=10&q=search
const response = await fetch('/api/admin/users?page=1&limit=10');
const { data } = await response.json();Fetch orders
// GET /api/admin/orders?page=1&limit=10
const response = await fetch('/api/admin/orders?page=1&limit=10');
const { data } = await response.json();Authorization check
if (!session?.user || session.user.role !== 'admin') {
return NextResponse.json(
{ success: false, error: 'Forbidden' },
{ status: 403 }
);
}Extending admin
- Add a new page under
src/app/admin/ - Add an API route under
src/app/api/admin/ - Enforce admin authorization
- Update the admin sidebar