@nuxtjs/better-auth

Nuxt module for Better Auth integration with NuxtHub, route protection, session management, and role-based access
13,368 147
Install
npm install @nuxtjs/better-auth
Latest Version:0.3.12
Vue:3
License:MIT
Last Updated:Oct 21, 2026
Links: GitHub  ·  npm
Maintainer: onmax_

@nuxtjs/better-auth

Nuxt module for Better Auth with Nuxt-native route protection, SSR-safe session access, auto-imported helpers, and optional NuxtHub-backed schema generation.

Who this is for

Use this module if you want Better Auth in a Nuxt app and you want the Nuxt-specific pieces handled for you:

  • useUserSession() for reactive auth state
  • requireUserSession(event) and related server helpers
  • route protection through routeRules and definePageMeta({ auth })
  • generated server/auth.config.ts and app/auth.config.ts
  • optional NuxtHub database integration and schema generation

Requirements

  • Nuxt 4.0 or newer
  • Node.js ^22.19.0, ^24.11.0, or >=26.0.0
  • A Better Auth 1.x version that satisfies this package's peer dependency range
  • NuxtHub 0.10.5 or newer when using the optional NuxtHub integration

Install the module

For the fastest path in a Nuxt app:

npx nuxi module add @nuxtjs/better-auth

Then create or confirm these files:

  • server/auth.config.ts
  • app/auth.config.ts
  • .env with NUXT_BETTER_AUTH_SECRET

For the full setup flow, follow the installation guide.

Choose your setup path

Documentation

The documentation site is at better-auth.nuxt.dev.

Recommended reading order:

  1. Quickstart
  2. Installation
  3. Configuration
  4. Client setup
  5. Route protection

Development

pnpm install
pnpm dev:docs

Useful commands:

  • pnpm dev to run the playground
  • pnpm dev:docs to run the docs site
  • pnpm lint to lint the repo
  • pnpm typecheck to check module types
  • pnpm prepack to build the publishable package
  • pnpm test to run the test suite
  • BETTER_AUTH_SECRET=ci-test-secret-12345678901234567890 pnpm dev:build to build the playground with a test secret for local verification only
  • pnpm build:docs to build the docs site

See CONTRIBUTING.md for the complete local CI sequence and pull request guidelines.

License

MIT

Related Packages

@nuxtjs/i18n

Internationalization for Nuxt

23,877,608 2,085
@nuxtjs/color-mode

Dark and light mode for Nuxt with auto detection

20,659,199 1,228
@nuxtjs/tailwindcss

Tailwind CSS module for Nuxt

16,852,917 1,868
@nuxtjs/sitemap

Powerfully flexible XML Sitemaps that integrate seamlessly, for Nuxt.

10,334,110 441
@nuxtjs/robots

Tame the robots crawling and indexing your Nuxt site with ease.

8,776,519 529

Version History

Version Released License
0.3.12 MIT
0.3.11 MIT
0.3.10 MIT
0.3.9 MIT
0.3.8 MIT