Organizations: inferAdditionalFields for separate client-server projects

In point two of Inferring Addional Fields on Client in the inferring additional fields docs there is the following example:
import type { auth } from "./auth";
import { inferAdditionalFields } from "better-auth/client/plugins";

export const authClient = createAuthClient({
plugins: [inferAdditionalFields({
user: {
role: {
type: "string"
}
}
})],
});
import type { auth } from "./auth";
import { inferAdditionalFields } from "better-auth/client/plugins";

export const authClient = createAuthClient({
plugins: [inferAdditionalFields({
user: {
role: {
type: "string"
}
}
})],
});
is there an equivalent for this for the newly added custom fields in organizations?
2 Replies
Ping
Ping2mo ago
Not right now, you best bet is to make a fake auth for the purpose of type inference.
const fakeAuth = betterAuth({
plugins: [organization({
schema: {/* ... */ }
})]
});

createAuthClient({
plugins: [organizationClient({ $inferAuth: {} as typeof fakeAuth })]
})
const fakeAuth = betterAuth({
plugins: [organization({
schema: {/* ... */ }
})]
});

createAuthClient({
plugins: [organizationClient({ $inferAuth: {} as typeof fakeAuth })]
})
I'll see if I can implement it tho.
Ping
Ping2mo ago
@phil I opened a PR, you can track it here: https://github.com/better-auth/better-auth/pull/3564
GitHub
feat(org): additional fields support separate client-server project...
With this, users with their auth separated in different projects can still support org additional fields inference on the client plugin. Summary by cubic Added support for passing the organizati...

Did you find this page helpful?