Nuxt Better Auth integrates Nuxt and Better Auth, the TypeScript-first authentication library. You get route protection, session management, and schema generation with minimal setup. The plugin ecosystem adds features like 2FA, organizations, and passkeys.
This module brings Nuxt-specific enhancements on top of Better Auth:
Auto Configuration
Auto-wires API routes, middleware, and schema with sensible defaults
Route Protection
Declarative page and API route guards
Schema Generation
Auto-generate Drizzle schemas
Reactive Sessions
useUserSession() with SSR support
Database Flexibility
Works standalone or with NuxtHub
Type Safety
Full TypeScript inference
Auto Imports
Composables and utils ready to use
Server Utilities
Auth helpers for your API routes
Powered by Better Auth
2FA, OAuth, SSO, organizations, and more
Building authentication from scratch is hard. Wiring up Better Auth with Nuxt manually involves:
This module does all of that for you. Just configure your auth providers and the module handles the rest.
Get a working login in 5 minutes with NuxtHub (SQLite).
npx nuxi module add @onmax/nuxt-better-auth@alpha @nuxthub/core
export default defineNuxtConfig({
hub: { db: 'sqlite' },
})
BETTER_AUTH_SECRET="generate-a-32-char-secret"
import { defineServerAuth } from '@onmax/nuxt-better-auth/config'
export default defineServerAuth({
emailAndPassword: { enabled: true },
})
import { defineClientAuth } from '@onmax/nuxt-better-auth/config'
export default defineClientAuth({})
pnpm dev
npm run dev
You now have API routes at /api/auth/*, a reactive useUserSession() composable, and route protection via definePageMeta.