How can I get other plugin's option in my plugin?

I'm building a plugin to extend organization plugin. I want to get organizationOptions so I can handle other stuff in the plugin. How can I achieve that? I tried
ctx.context.options.plugins?.find((plugin) => plugin.id === "organization")?.options
ctx.context.options.plugins?.find((plugin) => plugin.id === "organization")?.options
but that didn't work even though organization plugin is setup correctly...
5 Replies
KiNFiSH
KiNFiSH7d ago
you can import the org options interface as well -
import { organization, type OrganizationOptions } from "better-auth/plugins";
import { organization, type OrganizationOptions } from "better-auth/plugins";
Maqed
MaqedOP7d ago
I don't want the interface. I want the actual options itself. For example: I set up organization plugin with these options:
organization({
ac,
roles: { member, admin, owner },
}),
organization({
ac,
roles: { member, admin, owner },
}),
I want to access to access them in other plugin. How can I do such thing?
bekacru
bekacru6d ago
Not every plugin exposes its options. Including the org plugin. Unless you're planning to publish it, get or pass the options manually.
KiNFiSH
KiNFiSH6d ago
I just passed that so that you can extend on it through. But they are not exposing to each other as beka said
Maqed
MaqedOP6d ago
How can I get or pass the options manually? should I just pass it like that:
organization({
ac,
roles: { member, admin, owner },
}),
myPlugin({
ac,
roles: { member, admin, owner },
})
organization({
ac,
roles: { member, admin, owner },
}),
myPlugin({
ac,
roles: { member, admin, owner },
})

Did you find this page helpful?