Better Auth Plugins
Register typed client plugins and handle plugins that change the Better Auth component schema.
Additional Better Auth plugins have two sides:
- server configuration inside
createAuth; - client plugin methods exposed through
useConvexAuth().client.
Some plugins also change the Better Auth component schema.
Define client plugins
Create one convex-auth.ts at the Nuxt srcDir:
import { organizationClient } from 'better-auth/client/plugins'
import { defineConvexAuthClient } from 'better-convex-nuxt/auth-client'
export default defineConvexAuthClient({
plugins: [organizationClient()],
})The module discovers this file, prepends the required Convex client plugin, instantiates one client, and generates type registration.
The definition itself is frozen metadata. It never creates a client.
Configure the server plugin
import { organization } from 'better-auth/plugins'
return betterAuth({
database: authComponent.adapter(ctx),
plugins: [
organization({
teams: { enabled: true },
}),
convex({ authConfig }),
],
})Server and client plugin configuration must agree.
Call a typed plugin method
const { client } = useConvexAuth()
const organizations = await client?.organization.list()Keep operations that must trigger Convex identity coordination on the integrated signIn, signUp, and signOut surfaces.
Schema-changing plugins
Admin, organization, API-key, and similar plugins can add tables or fields. The safe path is:
- Define a local Better Auth component directory.
- Export the same plugin-aware Better Auth options used at runtime.
- Generate the component schema with the Better Auth/Convex tooling.
- Register the local component in
convex/convex.config.ts. - Create the component client with the generated local schema.
- Typecheck server and client plugin calls.
Use the repository's starters/team/convex/betterAuth and auth-security fixtures as the current reference shape.
Do not assume an arbitrary Better Auth plugin works because its client method typechecks. Verify schema, routes, runtime behavior, and security constraints for the pinned versions.