Docs/Admin/Seed Admin

Seed Admin User

Create your first admin user with elevated permissions.

Environment Variables

VariableDescriptionTypeSource
ADMIN_EMAILEmail address for the admin user*
server
safe
Your admin email
ADMIN_PASSWORDInitial password for the admin user*
server
secret
Generate a secure password

* Required variable

Option 1: Using Supabase Dashboard

The simplest way to create an admin user:

  1. Go to Supabase Dashboard
  2. Navigate to Authentication → Users
  3. Click "Add user"
  4. Enter the admin email and password
  5. Click "Create user"
  6. Note the user's UUID

Then update the user's role to admin in the profiles table:

-- Run in SQL Editor (Dashboard → SQL Editor)
UPDATE public.profiles
SET role = 'admin'
WHERE id = 'USER_UUID_HERE';

Option 2: Using Seed Script

Use the provided seed script for automated setup:

First, add to your .env.local:

.env.local
# Admin User Seeding
ADMIN_EMAIL=admin@yourdomain.com
ADMIN_PASSWORD=your-secure-password-here
Use a Strong Password
Generate a strong password with at least 12 characters, including uppercase, lowercase, numbers, and symbols.

Then run the seed command:

npm run db:seed:admin

Option 3: SQL Seed File

Add to your supabase/seed.sql file:

supabase/seed.sql
-- Note: This creates the user in auth.users
-- You'll need to use the Dashboard or a script for password setup

-- After the user exists, update their role:
-- UPDATE public.profiles SET role = 'admin' WHERE email = 'admin@yourdomain.com';
Auth User Creation
Supabase doesn't allow creating auth users directly via SQL. Use the Dashboard or the Admin API (via service role key) to create the initial user.

Verify Admin Access

  1. Start your development server
  2. Log in with your admin credentials
  3. Navigate to /admin or your admin route
  4. Verify you have access to admin features

Troubleshooting

"Access denied" to admin routes

Check that the user's role is set to 'admin' in the profiles table and that RLS policies are configured correctly.

Profile not created

Ensure your database has a trigger that creates a profile when a new auth user is created. Check the migrations for the trigger definition.

Setup Complete!

Congratulations! You've completed all the setup modules. Your VibeCodeMax application is now fully configured with:

  • • Supabase authentication and database
  • • Payment processing (if enabled)
  • • Email capabilities (if enabled)
  • • File storage (if enabled)
  • • Admin user management
Seed Admin User | Admin Module | VibeCodeMax Docs