Skip to content

nuxt-modules/better-auth

Repository files navigation

@onmax/nuxt-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.

Warning

This package is still in alpha. Expect API and behavior changes before a stable release.

Who this is for

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 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

Install the module

For the fastest path in a Nuxt 4 app:

npx nuxi module add @onmax/nuxt-better-auth@alpha

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 test to run the test suite
  • pnpm build:docs to build the docs site

License

MIT

About

The most comprehensive authentication framework for Nuxt.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages