[GH-ISSUE #2772] Organization plugin lacking metadata type-safety and JSON parsing #9343

Closed
opened 2026-04-13 04:46:46 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @ohkimur on GitHub (May 24, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/2772

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Create a new organization.
  2. Add metadata fields.
  3. Try to access this metadata from useActiveOrganization and/or useListOrganizations -> No type-safety and it's raw string instead of parsed JSON.

Current vs. Expected behavior

The current behavior is almost there, but we should be able to define a type schema for the metadata in an intuitive way. Additionally the metadata object although stored as a string in the db should be parsed by default with the right type.

Additionally we should have the ability to customize the organization schema through additionalFields such that we don't just have metadata, but we have the power of actually extending the organization schema properly. There are plenty of usecases where this would be very valuable.

What version of Better Auth are you using?

1.2.8

Provide environment information

MacOS, Arc Browser

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

Types

Auth config (if applicable)

import { betterAuth } from "better-auth"
import { organization } from 'better-auth/plugins'

export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
  plugins: [organization()]
});

Additional context

No response

Originally created by @ohkimur on GitHub (May 24, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/2772 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Create a new organization. 2. Add metadata fields. 3. Try to access this metadata from `useActiveOrganization` and/or `useListOrganizations` -> No type-safety and it's raw `string` instead of parsed JSON. ### Current vs. Expected behavior The current behavior is almost there, but we should be able to define a type schema for the metadata in an intuitive way. Additionally the metadata object although stored as a string in the db should be parsed by default with the right type. Additionally we should have the ability to customize the organization schema through `additionalFields` such that we don't just have metadata, but we have the power of actually extending the organization schema properly. There are plenty of usecases where this would be very valuable. ### What version of Better Auth are you using? 1.2.8 ### Provide environment information ```bash MacOS, Arc Browser ``` ### Which area(s) are affected? (Select all that apply) Types ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" import { organization } from 'better-auth/plugins' export const auth = betterAuth({ emailAndPassword: { enabled: true }, plugins: [organization()] }); ``` ### Additional context _No response_
GiteaMirror added the locked label 2026-04-13 04:46:46 -05:00
Author
Owner

@Kinfe123 commented on GitHub (May 28, 2025):

Metadata is designed to store a wide range of complex and dynamic data based on various use cases. This gives you greater flexibility when storing information in the metadata field, and you can handle typing in your application code, which feels quite intuitive.

<!-- gh-comment-id:2914657113 --> @Kinfe123 commented on GitHub (May 28, 2025): Metadata is designed to store a wide range of complex and dynamic data based on various use cases. This gives you greater flexibility when storing information in the metadata field, and you can handle typing in your application code, which feels quite intuitive.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#9343