Overview
Learn about the admin panel and how to manage your application.
The admin panel provides a comprehensive interface for managing users, organizations, subscriptions, credits, and application configuration. Only users with the admin role can access the admin panel.
Users
Organizations
Subscriptions
Credits
App Config
Getting Started
To access the admin panel, you need to:
- Create an admin user - Assign the
adminrole to a user (see Admin UI) - Log in - Sign in with the admin user account
- Navigate to Admin - Click on the "Admin" item in the navigation menu
The admin panel is located at /dashboard/admin and all routes under this path are automatically protected. Only users with the admin role can access these pages.
Accessing the Admin Panel
Once you've created an admin user and logged in, you'll see a new "Admin" item in the navigation menu. Clicking it will take you to the admin panel where you can:
- Manage Users - View, edit, and manage all users in the system
- Manage Organizations - View and manage all organizations
- View Analytics - Access system-wide analytics and metrics
- System Settings - Configure application-wide settings
Admin Panel Features
The admin panel includes the following management sections:
Users Management
- View all users - Browse and search through all registered users
- Filter users - Filter by role, verification status, ban status, and creation date
- Ban/Unban users - Temporarily or permanently ban user accounts
- Export users - Export user data to CSV
- View user details - See detailed information about each user
Organizations Management
- View all organizations - See all organizations in your system
- Filter organizations - Filter by various criteria
- Bulk actions - Perform actions on multiple organizations at once
- View organization details - See members, settings, and activity
Subscriptions Management
- View all subscriptions - Monitor all active and inactive subscriptions
- Filter subscriptions - Filter by status, plan, and date ranges
- Bulk actions - Manage multiple subscriptions simultaneously
- Subscription details - View payment history and subscription metadata
Credits Management
- View credits - See credit balances for users and organizations
- Adjust credits - Manually add or remove credits
- Credit history - Track credit transactions and adjustments
- Bulk credit operations - Adjust credits for multiple entities
App Config Management
- View configuration - See current application configuration
- Update settings - Modify application-wide settings
- Configuration history - Track changes to configuration
Admin Routes Protection
All admin routes are automatically protected using the protectedAdminProcedure in tRPC and route protection in Next.js:
import { redirect } from 'next/navigation';
import { getSession } from '@/lib/auth/server';
export default async function AdminLayout({
children
}: React.PropsWithChildren) {
const session = await getSession();
if (!session || session.user?.role !== 'admin') {
redirect('/dashboard');
}
return <>{children}</>;
}Admin tRPC Procedures
All admin tRPC procedures use protectedAdminProcedure which ensures only admin users can access them:
import { createTRPCRouter, protectedAdminProcedure } from '@/trpc/init';
export const adminUserRouter = createTRPCRouter({
list: protectedAdminProcedure
.input(listUsersAdminSchema)
.query(async ({ input }) => {
// Admin-only logic here
})
// ... other admin procedures
});Next Steps
Explore the individual admin panel sections to learn more about managing each aspect of your application:
- Users - User management and moderation
- Organizations - Organization management
- Subscriptions - Subscription and billing management
- Credits - Credit management and adjustments
- App Config - Application configuration