npx nuxi module add @onmax/nuxt-better-auth@alpha
nuxi module add, it prompts you to generate BETTER_AUTH_SECRET and can append it to your .env. In CI/test environments it auto-generates the 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
server/auth.config.ts and <srcDir>/auth.config.ts are scaffolded if missing. 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({})