New to better-auth
Hey folks, since better-auth generates own tables, can i modify that? I want it to be linked to my own users table, would that do anything bad?
20 Replies
Like, these are the tables that are generated by better-auth
But my table is gonna be something like this
you can modify it
Database | Better Auth
Learn how to use a database with Better Auth.
Yeah we recommend modifying it to suit your needs.
okay thanks you two
i need help please
this is my table now
How can i extend it?
in here,
i dont get it
looking from this link
i want role to be default to "superadmin"
Add the role field to your
additionalFields, within that you can pass a defaultValue.Like this

i want to pass other fields as well tho
Then add other fields
alr alr lemme see
another question, i will have 2 user forms, one will be normal one and another will be for inside dashboard, i want to make a role, if you signed up inside /signup, your role will automatically be "superadmin", but if you made user from /dashboard/moderators, you get role "editor", how would i do that?
* Add the
admin plugin from Better-auth docs
* I assume your moderators are essentially site admins if they're able to make new users - in such case you can use the admin plugin to call the authClient.admin.createUser to make a new user, and from there you can also pass a role which can be the editor.
Note that if you're using the admin plugin, the role will exist by default, so you don't need the additionalFields for a role. You will however have to look into the admin docs fully to ensure you understand how it works, as well as how to set default roles etc.Admin | Better Auth
Admin plugin for Better Auth
great, thats it, thank you
one more thing
result.error.message doesnt exist
how can i return errors
auth.api will throw an error, not return {data, error}
You need to use a try catch block
like this?
if no, can you give me an example or something please
im kinda new to this
@In&Out
Also try your best to avoid using auth.api unless absolutely necessary, by the way
how so?
i just want errors, like if user alraedy exists and stuff like that
im using auth.ts not auth-client if it matters
nevermind, figured it out
That's for server side use, if you want nice errors (as I have been doing so), I use authClient which does provide {data, error}. The types are nicely set for intellisense so it works like a charm
thank you
yeah yeah, just saw that, tho docs were bit rough on that
Once 1.3 is released hopefully the docs will be more clear about this
Sorry for the late replies by the way, I noticed you pinged me a few times yesterday - I had a dreadful headache so I went to sleep early 😅
no worries mate, i figured out the stuff i asked for anyways
cant wait
docs arent bad but are inconsistent
like this for example, i didnt see this anywhere in docs, probably was there but still idk,
had more examples but i forgot them ngl lol