bug: Database hooks do not comply with extended core schema #648

Closed
opened 2026-03-13 07:58:51 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @rokitgg on GitHub (Feb 10, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Extend core schema
user: {
    additionalFields: {
      address: {
        type: "string",
        required: true,
        defaultValue: "0x0000000000000000000000000000000000000000",
      },
    },
  },
  1. Write database hook, check user context.

  2. User context doesn't match or include the extended schema fields.

Image

Current vs. Expected behavior

Shouldn’t the extended schema fields be available in the database hooks?

What version of Better Auth are you using?

1.0.8

Provide environment information

- OS: macOS Sequoia 15.1.1
- Browser: Arc Browser

Which area(s) are affected? (Select all that apply)

Types

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
  user: {
    additionalFields: {
      address: {
        type: "string",
        required: true,
        defaultValue: "0x0000000000000000000000000000000000000000",
      },
    },
  },
});

Additional context

No response

Originally created by @rokitgg on GitHub (Feb 10, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Extend core schema ``` user: { additionalFields: { address: { type: "string", required: true, defaultValue: "0x0000000000000000000000000000000000000000", }, }, }, ``` 2. Write database hook, check user context. 3. User context doesn't match or include the extended schema fields. <img width="683" alt="Image" src="https://github.com/user-attachments/assets/c44d8a8f-4315-4cbd-acea-5d6e11c14c89" /> ### Current vs. Expected behavior Shouldn’t the extended schema fields be available in the database hooks? ### What version of Better Auth are you using? 1.0.8 ### Provide environment information ```bash - OS: macOS Sequoia 15.1.1 - Browser: Arc Browser ``` ### Which area(s) are affected? (Select all that apply) Types ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, user: { additionalFields: { address: { type: "string", required: true, defaultValue: "0x0000000000000000000000000000000000000000", }, }, }, }); ``` ### Additional context _No response_
GiteaMirror added the bug label 2026-03-13 07:58:51 -05:00
Author
Owner

@rv-bit commented on GitHub (Feb 10, 2025):

hi, you can cast it or extend it manually like this

before: async (user: User & { address?: string }) => {},

@rv-bit commented on GitHub (Feb 10, 2025): hi, you can cast it or extend it manually like this `before: async (user: User & { address?: string }) => {},`
Author
Owner

@rokitgg commented on GitHub (Feb 10, 2025):

Got it! Really appreciate it.

@rokitgg commented on GitHub (Feb 10, 2025): Got it! Really appreciate it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#648