Create app/auth.config.ts with a default export using defineClientAuth.
The defineClientAuth helper supports two syntaxes: an object for simple configurations, or a function when you need access to context like the resolved site URL.
import { defineClientAuth } from '@onmax/nuxt-better-auth/config'
// Object syntax (simplest)
export default defineClientAuth({})
// Function syntax (access context)
export default defineClientAuth(({ siteUrl }) => ({
// siteUrl contains the resolved base URL
}))
defineClientAuth returns a config factory. The module calls it with the resolved baseURL and creates the client at runtime.If you added a plugin in your server config (server/auth.config.ts), make sure to add its client equivalent here.
import { defineClientAuth } from '@onmax/nuxt-better-auth/config'
import { adminClient } from 'better-auth/client/plugins'
export default defineClientAuth({
plugins: [
adminClient() // Must match the server plugin
]
})
Modules can inject client plugins without requiring users to edit app/auth.config.ts.
export default defineNuxtConfig({
hooks: {
'better-auth:client:extend'(config) {
config.plugins = [
{
from: 'better-auth/client/plugins',
name: 'adminClient',
},
]
},
},
})
import { defineClientAuth } from '@onmax/nuxt-better-auth/config'
import { adminClient, twoFactorClient } from 'better-auth/client/plugins'
export default defineClientAuth({
plugins: [adminClient(), twoFactorClient()]
})