npx nuxi module add @onmax/nuxt-better-auth@alpha
nuxt prepare or nuxt dev auto-generates the .env file with a secure BETTER_AUTH_SECRET.Add these environment variables to .env:
The secret encrypts and hashes sensitive data. Must be at least 32 characters with high entropy.
BETTER_AUTH_SECRET=
Or generate via terminal:
openssl rand -base64 32
NUXT_ to use Nuxt's runtime config system (recommended for multi-environment deployments): NUXT_BETTER_AUTH_SECRET=The module auto-detects the URL on Vercel, Cloudflare Pages, and Netlify. Set manually for other platforms.
NUXT_PUBLIC_SITE_URL=https://your-domain.com
nuxt prepare or nuxt dev auto-generates these files. The client config is placed in your srcDir (e.g., app/ or project root).The module requires two configuration files:
server/auth.config.ts<srcDir>/auth.config.ts (e.g., app/auth.config.ts)Create these files with the following content:
import { defineServerAuth } from '@onmax/nuxt-better-auth/config'
export default defineServerAuth({
emailAndPassword: { enabled: true }
})
import { defineClientAuth } from '@onmax/nuxt-better-auth/config'
export default defineClientAuth({})