Create user with custom ID
I am trying to configure better-auth as an alternative to Cognito.
We are trying to migrate our users over, but since Cognito doesn't allow us to access the passwords, we need to do it when our user's log in. The idea is to log in with Cognito and sign the user into the better auth database. This means that the IDs should match.
Is it possible to create a user with a pre-set ID, so that the old Cognito and the new user IDs match?
4 Replies
Yeah, you can pass a
generateId
function in your better-auth config:
https://www.better-auth.com/docs/reference/options#advancedOptions | Better Auth
Better Auth configuration options reference.
Is there a way to pass it the id I want from the outside? It doesn't seem to have any parameter that would allow me to do that 😦
Yeah, you can't.
if you use something like drizzle you can prevent better auth from generating id, then you create your own id