Back to Skills

nuxt-better-auth

Use when implementing auth in Nuxt apps with @onmax/nuxt-better-auth - provides useUserSession composable, server auth helpers, route protection, and Better Auth plugins integration.

692stars34forksUpdated 7/30/2026

Security Assessment

Safe(93/100)
Security Score93/100

About nuxt-better-auth

The nuxt-better-auth skill is guidance for implementing authentication in Nuxt 4+ applications using the @onmax/nuxt-better-auth module, which is built on top of Better Auth. It solves the problem of wiring up sessions, login/signup/signout flows, and route protection in Nuxt without hand-rolling auth plumbing, providing a useUserSession composable on the client and server helpers such as serverAuth, getUserSession, and requireUserSession. The skill is upfront that the module is in alpha (v0.0.2-alpha.19) and not recommended for production, with APIs subject to change.

Structured as a routing surface with a table of reference files, it covers installation and configuration (module setup, env vars, config files), client auth flows, server-side session access, route protection via routeRules and definePageMeta, Better Auth plugin integration (admin, passkey, two-factor), NuxtHub database setup with Drizzle schemas, clientOnly mode for external auth backends with CORS, and TypeScript type augmentation. It instructs loading only the reference relevant to the current task rather than all files. Credential handling follows standard practice: a BETTER_AUTH_SECRET of at least 32 characters supplied via environment variable or runtimeConfig, and OAuth client IDs/secrets pulled from runtime config.

Target users are Nuxt developers adding authentication to their apps, including those needing OAuth social providers, passkeys, 2FA, or an external auth backend. Use cases span building login and signup flows, protecting pages and API routes, accessing the user session in server routes, and setting up a session database on NuxtHub.

FAQ

Is this module production-ready?

No. The skill states the module is in alpha (v0.0.2-alpha.19) and not recommended for production use, and warns that APIs may change.

What versions does it require?

Nuxt 4+, @onmax/nuxt-better-auth ^0.0.2-alpha.19, better-auth ^1.0.0 (tested with 1.4.7), and optionally @nuxthub/core 0.10.5+ for database support.

How are secrets configured?

Via a BETTER_AUTH_SECRET environment variable of at least 32 characters (or runtimeConfig.betterAuthSecret, which takes priority), plus NUXT_PUBLIC_SITE_URL for OAuth in production and OAuth client credentials sourced from runtime config.

How do I protect routes?

Using routeRules, definePageMeta, or middleware on the client, and requireUserSession on the server, which throws a 401/403 if the user is not authenticated. An auth route mode supports 'user', 'guest', object-based role checks, or false.

Can I use an external auth backend?

Yes. Setting clientOnly: true enables clientOnly mode for external auth backends or microservices, with CORS setup covered in references/client-only.md.

All Files

9 files
references/installation.md4.0 KB
View
SKILL.md4.7 KB
View
references/client-only.md3.0 KB
View
references/server-auth.md3.1 KB
View
references/database.md3.8 KB
View
references/types.md2.4 KB
View
references/client-auth.md3.2 KB
View
references/route-protection.md2.3 KB
View
references/plugins.md2.5 KB
View

Install nuxt-better-auth

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill