Admin Access
Managing who has access to the administrative parts of your dashboard is vital. NextAdmin makes this process straightforward through environment-based configuration and database roles.
Enabling Admin Privileges
The administrative dashboard is reserved for users with the ADMIN role. There are two primary ways to grant this role.
1. Using Environment Variables (Recommended for Initial Setup)
During development or initial rollout, you can automatically grant the ADMIN role to specific emails by adding them to your .env file.
Add your email to the ADMIN_EMAILS variable. If you have multiple administrators, separate their emails with a comma:
# Single admin
ADMIN_EMAILS="yourname@gmail.com"
# Multiple admins
ADMIN_EMAILS="admin1@example.com,admin2@example.com,admin3@example.com"How it works: When a user registers with an email that exists in this list, NextAdmin automatically assigns them the ADMIN role in the database.
2. Database Modification
For users who are already registered, you can manually update their role in the database using the Prisma Studio or any SQL client.
npx prisma studioSimply find the user record and change the role field from USER to ADMIN.
What Admin Access Unlocks
Once a user is granted ADMIN status, they gain access to:
- The full Admin Dashboard layout.
- User management interfaces.
- System-wide configuration settings.
- Protected API routes and server actions.
TIP: After setting up your initial admin accounts, you might want to remove the
ADMIN_EMAILSfrom your.envfile in production for better security, and manage roles entirely via the database or an admin UI.