Getting Started

Installation

Get started with Nuxt Better Auth in your project.

Install

Install the module and required peer dependencies:

pnpm add @onmax/nuxt-better-auth better-auth drizzle-orm @nuxthub/core

If you want the shortest path to a working setup, follow /getting-started/quickstart.

Add to Nuxt

Enable NuxtHub database and register the module in nuxt.config.ts:

export default defineNuxtConfig({
  modules: ['@nuxthub/core', '@onmax/nuxt-better-auth'],

  // NuxtHub database must be enabled
  hub: {
    db: {
      dialect: 'sqlite', // 'sqlite' | 'postgresql' | 'mysql'
    },
  },

  runtimeConfig: {
    betterAuthSecret: process.env.BETTER_AUTH_SECRET,
    public: {
      siteUrl: process.env.NUXT_PUBLIC_SITE_URL || 'http://localhost:3000',
    },
  },
})

Required config files

The module validates these files at build time:

  • server/auth.config.ts (server Better Auth config)
  • app/auth.client.ts (client factory)

Next:

  • Create your server config: /getting-started/configuration
  • Create your client config: /getting-started/client-setup
  • Add types: /getting-started/type-augmentation
  • Browse Better Auth plugins/providers: /better-auth