Nuxt module for Better Auth with Nuxt-native route protection, SSR-safe session access, auto-imported helpers, and optional NuxtHub-backed schema generation.
Warning
This package is still in alpha. Expect API and behavior changes before a stable release.
Use this module if you want Better Auth in a Nuxt 4 app and you want the Nuxt-specific pieces handled for you:
useUserSession()for reactive auth staterequireUserSession(event)and related server helpers- route protection through
routeRulesanddefinePageMeta({ auth }) - generated
server/auth.config.tsandapp/auth.config.ts - optional NuxtHub database integration and schema generation
For the fastest path in a Nuxt 4 app:
npx nuxi module add @onmax/nuxt-better-auth@alphaThen create or confirm these files:
server/auth.config.tsapp/auth.config.ts.envwithNUXT_BETTER_AUTH_SECRET
For the full setup flow, follow the installation guide.
- Use NuxtHub integration if you want the shortest path to database-backed auth.
- Use custom database setup if you already have your own database stack.
- Use external auth backend if Better Auth runs in a separate service.
- Use database-less mode for stateless or OAuth-first setups with clear tradeoffs.
The documentation site is at better-auth.nuxt.dev.
Recommended reading order:
pnpm install
pnpm dev:docsUseful commands:
pnpm devto run the playgroundpnpm dev:docsto run the docs sitepnpm lintto lint the repopnpm testto run the test suitepnpm build:docsto build the docs site