nuxt-better-auth
onmax/nuxt-skills
Guides authentication in Nuxt apps using @nuxtjs/better-auth with client/server APIs, route protection, and session management.
What is nuxt-better-auth?
A reference skill for implementing authentication in Nuxt applications via the @nuxtjs/better-auth module. Use it when installing the module, configuring environment variables, building auth forms, protecting routes, managing sessions, or integrating Better Auth plugins.
- Install and configure @nuxtjs/better-auth with environment variables
- Read and manage client session state, build authentication forms, and call auth plugins
- Enforce sessions in server handlers, create sessions, and refresh cached session data
- Protect pages and API routes with redirects and route rules
- Register Better Auth plugins and their client companions
- Configure NuxtHub, database schema, and secondary storage
How to install nuxt-better-auth
npx skills add https://github.com/onmax/nuxt-skills --skill nuxt-better-auth- Nuxt 3 application
- @nuxtjs/better-auth module installed
How to use nuxt-better-auth
- 1.Choose the relevant reference guide based on your task (installation, client auth, server auth, route protection, plugins, database, or client-only mode)
- 2.Follow the reference documentation for your specific use case
- 3.Confirm your installed package version supports the APIs you're using
- 4.For server-side changes to session payload, call refreshSessionCookieCache(event)
- 5.Wrap custom client auth endpoints that modify the current session with runWithSessionRefresh()
- 6.Run typecheck and relevant auth tests before finishing implementation
Use cases
- Setting up authentication in a new Nuxt application with environment configuration
- Building login/signup forms that read client session state and call auth endpoints
- Protecting API routes and pages with server-side session enforcement via requireUserSession()
- Refreshing session data after server-side mutations to session payload fields
- Integrating third-party Better Auth plugins with their client companions
- Nuxt application developers
- Full-stack engineers building authenticated web applications
- Teams implementing Better Auth in Nuxt projects
nuxt-better-auth FAQ
Use it to enforce protected API reads and mutations server-side. It ensures the user has a valid session before allowing access to sensitive endpoints.
Client APIs read session state and build forms; server APIs read/enforce sessions in handlers, create sessions, and manage cached session data.
Call refreshSessionCookieCache(event) after modifying session payload fields, and wrap custom client auth endpoints that change the current session with runWithSessionRefresh().
Yes, but do not use local server helpers or expect SSR session hydration in client-only mode. Use the client-only reference guide for external Better Auth server setups.
Run the consumer's typecheck and the narrowest relevant auth test to ensure your implementation is correct.
Full instructions (SKILL.md)
Source of truth, from onmax/nuxt-skills.
name: nuxt-better-auth description: Guides authentication in Nuxt apps using @nuxtjs/better-auth. Use when installing or configuring the module, using its client or server APIs, protecting routes, refreshing sessions, or integrating Better Auth plugins. license: MIT
Nuxt Better Auth
Use the smallest reference that matches the task.
Pick a reference
| Task | Read |
|---|---|
| Install the module, configure environment variables, or create config files | references/installation.md |
| Read client session state, build auth forms, call plugins, or fetch auth-bound data | references/client-auth.md |
| Read or enforce sessions in server handlers, create sessions, or refresh cached session data | references/server-auth.md |
| Protect pages or API routes and configure redirects | references/route-protection.md |
| Register Better Auth plugins and their client companions | references/plugins.md |
| Configure NuxtHub, generated schema, or secondary storage | references/database.md |
| Connect a Nuxt frontend to an external Better Auth server | references/client-only.md |
| Use inferred auth types or add project fields | references/types.md |
Rules that apply across tasks
- Confirm the consumer's installed package version supports each API you use. The published skill may be newer than the consumer's lockfile.
- Enforce protected API reads and mutations server-side with
requireUserSession(event). Route rules and page meta also control navigation. - Navigate only to validated local redirect paths.
- In
clientOnlymode, do not use local server helpers or expect SSR session hydration. - After server-side changes to session payload fields, call
refreshSessionCookieCache(event). Wrap custom client auth endpoints that create or change the current session withrunWithSessionRefresh().
Before finishing an implementation, run the consumer's typecheck and the narrowest relevant auth test.
Resources
Related skills
More from onmax/nuxt-skills and the wider catalog.

nuxt-content
Build typed, content-driven Nuxt applications with collections, queries, and Markdown rendering.

nuxt-modules
Create, test, and publish Nuxt modules with defineNuxtModule patterns, Kit utilities, and CI/CD automation.

nuxt-seo
Nuxt SEO meta-module for robots.txt, sitemaps, OG images, and structured data.

nuxt-studio
Configure and operate self-hosted Nuxt Studio editor for Nuxt Content projects.

nuxthub
Full-stack Nuxt with type-safe database, KV, blob storage, and cache—multi-cloud ready.

pnpm
Manage Node.js dependencies with pnpm—monorepos, workspaces, catalogs, and supply chain security.