Lovablefeatureadvanced
Add Admin Dashboard to Lovable App
Add a full admin panel with metrics, user management, content CRUD, and role-based access control.
What you'll get
A full admin dashboard with metrics, user management, content CRUD, settings, and audit logging.
The Prompt
Add a comprehensive admin dashboard to my Lovable app. REQUIREMENTS: 1. Create an /admin route group that is only accessible to users with role="admin" in their profile. Redirect non-admins to the home page with an error toast. 2. Dashboard overview page with KPI cards: total users, new users (last 7 days), total revenue, active subscriptions. Use Recharts for a line chart of signups over the last 30 days. 3. User management page: searchable/sortable table of all users with columns for name, email, role, signup date, subscription status. Actions: view profile, change role, suspend/activate, delete. 4. Content management page: CRUD interface for managing the main content type (posts, products, listings, etc.). Table view with inline editing, bulk actions (delete, publish/unpublish), and a create/edit form. 5. Settings page: manage site-wide settings (site name, description, contact email, social links) stored in a "site_settings" table. 6. Activity log page: recent admin actions (user changes, content edits, setting updates) stored in an "admin_audit_log" table. DATABASE: - Add "role" column to profiles table (default: "user", options: "user", "admin") - "site_settings" table: id, key, value, updated_at - "admin_audit_log" table: id, admin_user_id, action, target_type, target_id, details (jsonb), created_at - RLS: Only admins can read/write admin tables SECURITY: - Check role server-side, not just client-side. - Log all admin actions to the audit trail. - Require re-authentication for destructive actions (delete user, change roles).
Replace these variables
| Variable | Replace with |
|---|---|
| [CONTENT_TYPE] | Primary content type to manage (e.g., posts, products, listings) |
| [KPI_METRICS] | Key metrics to display on the dashboard |
Tips for best results
Seed an admin user in Supabase by manually setting role='admin' on your profile row.
Always check roles on the server (RLS policies) — client-side checks alone are not secure.
Add confirmation dialogs for destructive actions like deleting users or content.
Follow-up prompts
Add admin notifications
Add real-time notifications in the admin dashboard for new user signups, form submissions, and errors using Supabase Realtime.
Add export
Add CSV and PDF export buttons to the user management and content tables. Include date range filtering for exports.