[GH-ISSUE #615] databaseHooks add organization #16974

Closed
opened 2026-04-15 14:55:07 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @productdevbook on GitHub (Nov 21, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/615

databaseHooks: {
      organization: {
        create: {
          before: async (user) => {
            return {
              data: user,
            }
          },
        },
      },
    },

I'm always frustrated when I need to manually add new organizations to the database, which is time-consuming and error-prone.

Describe the solution you'd like

I would like a set of database hooks that automate the process of adding an organization to the database, ensuring consistent and accurate data handling.

Describe alternatives you've considered

Currently, I’ve considered using manual insert queries or a separate API for adding organizations, but neither offers the automation or integration I’m looking for.

Additional context

The new hooks should handle necessary validation, default values, and associations with other data (like users, permissions, etc.) automatically when a new organization is added.

Originally created by @productdevbook on GitHub (Nov 21, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/615 ``` example databaseHooks: { organization: { create: { before: async (user) => { return { data: user, } }, }, }, }, ``` ## Is your feature request related to a problem? Please describe. I'm always frustrated when I need to manually add new organizations to the database, which is time-consuming and error-prone. ## Describe the solution you'd like I would like a set of database hooks that automate the process of adding an organization to the database, ensuring consistent and accurate data handling. ## Describe alternatives you've considered Currently, I’ve considered using manual insert queries or a separate API for adding organizations, but neither offers the automation or integration I’m looking for. ## Additional context The new hooks should handle necessary validation, default values, and associations with other data (like users, permissions, etc.) automatically when a new organization is added.
GiteaMirror added the enhancementlocked labels 2026-04-15 14:55:07 -05:00
Author
Owner

@Bekacru commented on GitHub (Mar 21, 2025):

For organization creation, you now have beforeCreate and afterCreate hooks

https://www.better-auth.com/docs/plugins/organization#organization-creation-hooks

<!-- gh-comment-id:2743280676 --> @Bekacru commented on GitHub (Mar 21, 2025): For organization creation, you now have `beforeCreate` and `afterCreate` hooks https://www.better-auth.com/docs/plugins/organization#organization-creation-hooks
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#16974