Skip to content

Admin Dashboard

TSKit includes an admin dashboard at /admin for managing users, subscriptions, plans, and viewing audit logs. Only users with the admin role can access it.

The admin section is protected by adminMiddleware, which chains auth and rate limiting. If a non-admin user tries to access any admin page, they are redirected to /dashboard.

The admin role is set on the user record in the database. Better Auth’s admin plugin provides the API for promoting and banning users.

The admin dashboard has five pages:

A summary view with key metrics - total users, active subscriptions, revenue, and recent activity.

List and search users. Admins can:

  • View user details (email, signup date, verification status, role)
  • Ban or unban users
  • Impersonate users for debugging

View all active subscriptions across organizations. Shows the plan, status, billing period, and organization.

Manage subscription plans. View plan details, entitlements, pricing, and the number of active subscribers on each plan.

Browse the full audit trail across the app. Filter by action type, date range, and actor. Uses cursor-based pagination for performance.

The admin section follows the same layered pattern as the rest of the app:

  • Routes in routes/admin/ - Thin page shells with loaders that fetch and return data
  • Server functions in functions/admin/ - Split by domain (overview, users, subscriptions, plans, audit)
  • Services in services/admin/ - Business logic and queries, also split by domain

All admin server functions use adminMiddleware, which handles both authentication and role verification.

FilePurpose
routes/admin/Admin page routes
functions/admin/Admin server functions (overview, users, subscriptions, plans, audit)
services/admin/Admin services
middleware/admin.tsAdmin middleware (auth + role check + rate limit)