Admin-plugin. Is there an elegant way to create first app admin?
Possibly dumb question but for the admin plugin is there an elegant way to create the first admin in your app. I know you can 1. manually go check their id then add it to the better auth adminUserIds setting or 2. sign them up on db bootup and write a query in your db of choice to change their role, but 1. requires you to patch the code right after you just deployed it and 2. brakes the nice db encapsulation better auth has going on. Neither are bad options, but it feels off. Like I'm potential missing something. Like is there a backend only method that could just directly create the first admin without already being an admin or something?
3 Replies
im dealing with the same problem, mi stack is NUXT + DRIZZLE + CLUDFLARE D1, and the problem is Nuxt dont have an startup server hook. would be great a CLI COMMAND to create users, like Laravel
im trying with these options that i have seen in another apps before
1. write a seeder to create the first admin
2. a function on server startup that validate if exist a super admin, taking the super admin password form env vars. you can verify is already created the super admin before and do nothing
3. allow signup as a admin only if there are no users in database (like hestia panel or anothers server panel management apps)
Solution
update:
It's been awhile but I'm finally seeing this. Your GOATed.