Install the module and required peer dependencies:
pnpm add @onmax/nuxt-better-auth better-auth drizzle-orm @nuxthub/core
If you want the shortest path to a working setup, follow /getting-started/quickstart.
Enable NuxtHub database and register the module in nuxt.config.ts:
export default defineNuxtConfig({
modules: ['@nuxthub/core', '@onmax/nuxt-better-auth'],
// NuxtHub database must be enabled
hub: {
db: {
dialect: 'sqlite', // 'sqlite' | 'postgresql' | 'mysql'
},
},
runtimeConfig: {
betterAuthSecret: process.env.BETTER_AUTH_SECRET,
public: {
siteUrl: process.env.NUXT_PUBLIC_SITE_URL || 'http://localhost:3000',
},
},
})
The module validates these files at build time:
server/auth.config.ts (server Better Auth config)app/auth.client.ts (client factory)Next:
/getting-started/configuration/getting-started/client-setup/getting-started/type-augmentation/better-auth