[GH-ISSUE #4903] Support for Custom Fields in the Account Schema #27428

Closed
opened 2026-04-17 18:26:46 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @j-xzy on GitHub (Sep 25, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/4903

Is this suited for github?

  • Yes, this is suited for github

Currently, better-auth works seamlessly with its core schema for the Account model. However, in many real-world applications, developers need to extend the Account schema to store additional, provider-specific, or application-specific data.

For example, one might need to store:

  • A team_id when linking a Slack account.
  • A tenant_id for multi-tenant applications.
  • An status enum (ACTIVE, REVOKED) to manage the state of the connection.
  • A bot_id or other metadata returned from the OAuth provider's token response.

Describe the solution you'd like

betterAuth({
	account: {
		additionalFields: {
			clientId: {
				type: 'string',
				required: true,
			},
		},
	},
});

Describe alternatives you've considered

betterAuth({
	databaseHooks: {
		account: {
			create: {
				after: async (account) => {
					this.prismaService.account.update({
						data: {
							clientId: config.clientId,
						},
						where: {
							id: account.id,
						},
					});
				},
			},
		},
	},
});

Additional context

No response

Originally created by @j-xzy on GitHub (Sep 25, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/4903 ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. Currently, better-auth works seamlessly with its core schema for the Account model. However, in many real-world applications, developers need to extend the Account schema to store additional, provider-specific, or application-specific data. For example, one might need to store: - A team_id when linking a Slack account. - A tenant_id for multi-tenant applications. - An status enum (ACTIVE, REVOKED) to manage the state of the connection. - A bot_id or other metadata returned from the OAuth provider's token response. ### Describe the solution you'd like ``` betterAuth({ account: { additionalFields: { clientId: { type: 'string', required: true, }, }, }, }); ``` ### Describe alternatives you've considered ``` betterAuth({ databaseHooks: { account: { create: { after: async (account) => { this.prismaService.account.update({ data: { clientId: config.clientId, }, where: { id: account.id, }, }); }, }, }, }, }); ``` ### Additional context _No response_
GiteaMirror added the lockedenhancement labels 2026-04-17 18:26:46 -05:00
Author
Owner

@dvanmali commented on GitHub (Sep 25, 2025):

Hi @j-xzy This feature should be available as you described. is something missing from the docs?

<!-- gh-comment-id:3335267869 --> @dvanmali commented on GitHub (Sep 25, 2025): Hi @j-xzy This feature should be available as you described. is something missing from the [docs](https://www.better-auth.com/docs/concepts/database#extending-core-schema)?
Author
Owner

@j-xzy commented on GitHub (Sep 26, 2025):

@dvanmali https://www.better-auth.com/docs/concepts/database#extending-core-schema
Schema extension is only available for the User and Session tables, not for the Account table.

<!-- gh-comment-id:3336602635 --> @j-xzy commented on GitHub (Sep 26, 2025): @dvanmali https://www.better-auth.com/docs/concepts/database#extending-core-schema Schema extension is only available for the User and Session tables, not for the Account table.
Author
Owner

@AlexErrant commented on GitHub (Nov 23, 2025):

Can this issue be reopened? I quote from the above PR: "But in conclusion, this PR, for now, is incomplete."

<!-- gh-comment-id:3567164629 --> @AlexErrant commented on GitHub (Nov 23, 2025): Can this issue be reopened? I quote from [the above PR](https://github.com/better-auth/better-auth/pull/4935#issuecomment-3372643367): "But in conclusion, this PR, for now, is incomplete."
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#27428