The Convex auth config for your project. Typically exported from convex/auth.config.ts.The config must include a provider with applicationID: "convex". Use getAuthConfigProvider() from @convex-dev/better-auth/auth-config to generate it:
convex/auth.config.ts
import { type AuthConfig } from "convex/server";import { getAuthConfigProvider } from "@convex-dev/better-auth/auth-config";export default { providers: [getAuthConfigProvider()],} satisfies AuthConfig;
Custom function to define the JWT payload. Receives { user, session } and returns a plain object.The sessionId and iat (issued-at) fields are always appended automatically regardless of what this function returns.Default behavior — includes all user fields except id and image, plus sessionId and iat:
Optional static JWKS string for performance optimization. When provided, the plugin uses this value instead of fetching JWKS from the database, eliminating network round-trips during token validation.See Static JWKS for setup instructions.
Optional Better Auth options passed to the plugin. Currently used primarily to provide a custom basePath when your Better Auth config uses a non-default path.
If your Better Auth configuration uses a custom basePath, you must pass the
same value in options.basePath so the JWKS endpoint URL is constructed
correctly. A mismatch will cause token validation to fail.
The client plugin provides type inference for the Better Auth client so response types from Convex-specific endpoints are available. It has no configuration options.
lib/auth-client.ts
import { createAuthClient } from "better-auth/react";import { convexClient } from "@convex-dev/better-auth/client/plugins";export const authClient = createAuthClient({ plugins: [convexClient()],});