[GH-ISSUE #7411] Default types augmentation #10805

Open
opened 2026-04-13 07:09:56 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @mifopen on GitHub (Jan 16, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/7411

Originally assigned to: @ping-maxwell on GitHub.

Is this suited for github?

  • Yes, this is suited for github

Is your feature request related to a problem? Please describe.

It would be great to have an ability to override some default field types.
We have two use cases:

  1. We use typed string literal ids across the system (e.g. user id is usr_${string}, etc.)
  2. organization.metadata could be typed

Describe the solution you'd like

Declaration merging via .d.ts

Describe alternatives you've considered

Package patching

Additional context

No response

Originally created by @mifopen on GitHub (Jan 16, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/7411 Originally assigned to: @ping-maxwell on GitHub. ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. It would be great to have an ability to override some default field types. We have two use cases: 1. We use typed string literal ids across the system (e.g. user id is `usr_${string}`, etc.) 2. organization.metadata could be typed ### Describe the solution you'd like Declaration merging via .d.ts ### Describe alternatives you've considered Package patching ### Additional context _No response_
GiteaMirror added the enhancementcore labels 2026-04-13 07:09:56 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Jan 16, 2026):

It looks like your feature request for overriding default field types in Better Auth could potentially be managed through declaration merging using .d.ts files. To address your use cases, you may want to consider using the additionalFields property within the user or session object in your auth config to add custom fields as needed. This allows you to define the types you want while keeping everything type-safe and extensible for your use case with typed string literal IDs.

For example, your config could look something like this:

import { betterAuth } from "better-auth";

export const auth = betterAuth({
  user: {
    additionalFields: {
      userId: { type: "string", required: true },
      // Other custom fields can be added here
    },
  },
});

Additionally, feel free to explore existing plugins and how they might assist with standardizing types across your application.

If you need further insights or have more specific questions about your implementation, don’t hesitate to tag @bekacru or @ping__ for further assistance! What specific types are you looking to override, and how do you envision using them in your application?

If you need more help, tag @better-auth-agent in a comment so I can respond.

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3759788265 --> @better-auth-agent[bot] commented on GitHub (Jan 16, 2026): It looks like your feature request for overriding default field types in Better Auth could potentially be managed through declaration merging using `.d.ts` files. To address your use cases, you may want to consider using the `additionalFields` property within the user or session object in your auth config to add custom fields as needed. This allows you to define the types you want while keeping everything type-safe and extensible for your use case with typed string literal IDs. For example, your config could look something like this: ```typescript import { betterAuth } from "better-auth"; export const auth = betterAuth({ user: { additionalFields: { userId: { type: "string", required: true }, // Other custom fields can be added here }, }, }); ``` Additionally, feel free to explore existing plugins and how they might assist with standardizing types across your application. If you need further insights or have more specific questions about your implementation, don’t hesitate to tag @bekacru or @ping__ for further assistance! What specific types are you looking to override, and how do you envision using them in your application? _If you need more help, tag @better-auth-agent in a comment so I can respond._ <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) • [Discord](https://discord.gg/better-auth) • [GitHub](https://github.com/better-auth/better-auth) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/better-auth) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/better-auth/better-auth)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#10805