Where to pass `forceAllowId` ?

I need to customize the ID generation for the User table by passing an existing user ID instead of letting the system auto-generate one. I found the documentation at https://www.better-auth.com/docs/guides/create-a-db-adapter for creating a custom adapter, but the section about user ID generation is unclear:
additionally, it's possible to pass forceAllowId as a parameter to the create method, which allows id to be provided in the data object. We handle forceAllowId internally, so you don't need to worry about it.
additionally, it's possible to pass forceAllowId as a parameter to the create method, which allows id to be provided in the data object. We handle forceAllowId internally, so you don't need to worry about it.
My question is: Where exactly should I pass the forceAllowId parameter in the create method? I tried the following code, but forceAllowId doesn't seem to work:
// forceAllowId is not working as expected
const newUser = await adapter.createUser({
forceAllowId: true,
id: userData.id,
userId: userData.id,
name: userData.name!,
email: userData.email!,
emailVerified: userData.emailVerified || false,
image: userData.image || null,
});
// forceAllowId is not working as expected
const newUser = await adapter.createUser({
forceAllowId: true,
id: userData.id,
userId: userData.id,
name: userData.name!,
email: userData.email!,
emailVerified: userData.emailVerified || false,
image: userData.image || null,
});
Could someone clarify the correct syntax for using forceAllowId to allow custom user ID creation?
Create a Database Adapter | Better Auth
Learn how to create a custom database adapter for Better-Auth
1 Reply
Wendaolee
WendaoleeOP3mo ago
Question solved: I haven't clarify the adpater and internalAdapter's diffrence. Previous code I use:
const adapter = ctx.context.internalAdapter;
const adapter = ctx.context.internalAdapter;
What a stupid quesition.

Did you find this page helpful?