This library is in early development. Expect breaking changes.
Auth for Nuxt

The most comprehensive authentication framework for Nuxt.

git:(main)x

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

export default defineNuxtConfig({
  modules: ['@onmax/nuxt-better-auth'],
  routeRules: {
    '/dashboard/**': { auth: 'user' },
    '/admin/**': { auth: 'admin' },
  },
})
import { defineServerAuth } from '@onmax/nuxt-better-auth/config'
import { admin, twoFactor } from 'better-auth/plugins'

export default defineServerAuth({
  socialProviders: {
    github: { clientId: '...', clientSecret: '...' },
    google: { clientId: '...', clientSecret: '...' },
  },
  plugins: [admin(), twoFactor()],
})
import { defineClientAuth } from '@onmax/nuxt-better-auth/config'
import { adminClient, twoFactorClient } from 'better-auth/client/plugins'

export default defineClientAuth({
  plugins: [adminClient(), twoFactorClient()],
})
<script setup lang="ts">
const { signIn } = useUserSession()
</script>

<template>
  <button @click="signIn.social({ provider: 'github' })">
    Sign in with GitHub
  </button>
</template>

27+ Plugins

Two-factor auth, organizations, API keys, magic links, and more. All plugins work out of the box. Learn more

33+ OAuth Providers

Google, GitHub, Discord, Apple, and 30+ more social providers ready to use. Learn more

Database Flexibility

Works without a database for OAuth-only, or integrates with NuxtHub for full persistence. Learn more

Auto Schema Generation

Auth tables generated automatically from your plugins. Zero manual migrations. Learn more

SSR-Safe Sessions

useUserSession composable works seamlessly on server and client with automatic hydration. Learn more

Declarative Route Protection

Protect routes with routeRules. Define auth requirements once, enforce everywhere. Learn more

Nuxt + Better Auth

Set up authentication in minutes, not hours!