Callback that activates when a new user is created? (docs are not accurate)

The docs suggest the following to listen to when a new user is created:

export const auth = betterAuth({
    hooks: {
        after: createAuthMiddleware(async (ctx) => {
            if(ctx.path.startsWith("/sign-up")){
                const newSession = ctx.context.newSession;
                if(newSession){
                    sendMessage({
                        type: "user-register",
                        name: newSession.user.name,
                    })
                }
            }
        }),
    },
});


In practice,
  1. The path /sign-up doesn't exist. But /callback/:id does.
  2. /callback/:id (might, not sure) be called on every login and not just sign-up
  3. /callback/:id is not called from the Expo client
What is the correct way to figure get a notification when a new user is created (and I want their email + name)
Solution
Solved. Use databaseHooks -> user -> create -> after.
Was this page helpful?