template/.claude/skills/nuxt-auth-utils/SKILL.md
Use when implementing auth in Nuxt apps with nuxt-auth-utils - provides useUserSession composable, OAuth handlers, cookie-based sessions, and route protection. Works on all deployment targets without DB dependency.
npx skillsauth add charles5277/nuxt-supabase-starter nuxt-auth-utilsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Cookie-based authentication module for Nuxt. No database required for session storage — sessions are encrypted and stored in cookies.
nuxt-auth-utilsFor Nuxt patterns: use nuxt skill
For better-auth (DB-based auth): use nuxt-better-auth skill
| File | Topics | | ---------------------------------------------------------- | ------------------------------------------------------------------ | | references/client-auth.md | useUserSession, OAuth login, logout, session state | | references/server-auth.md | requireUserSession, getUserSession, setUserSession, OAuth handlers |
DO NOT load all files at once. Load only what's relevant to your current task.
| Concept | Description |
| -------------------------- | --------------------------------------------------------- |
| useUserSession() | Client composable — user, loggedIn, session, fetch, clear |
| requireUserSession() | Server helper — throws 401 if not authenticated |
| setUserSession() | Server helper — set session after OAuth success |
| clearUserSession() | Server helper — clear session (logout) |
| defineOAuth*EventHandler | Server OAuth callback handlers |
| auth.d.ts | Type augmentation via declare module '#auth-utils' |
// Client: useUserSession()
const { user, loggedIn, clear } = useUserSession()
// Server: OAuth handler
export default defineOAuthGoogleEventHandler({
async onSuccess(event, { user: googleUser }) {
await setUserSession(event, {
user: { id: googleUser.sub, email: googleUser.email, name: googleUser.name },
})
return sendRedirect(event, '/')
},
})
// Server: protect API route
const { user } = await requireUserSession(event)
| | nuxt-auth-utils | better-auth |
| ------------ | --------------- | ----------------------------------------------- |
| Session 儲存 | Cookie(無 DB) | Database |
| 登入方式 | OAuth only | Email/Password + OAuth |
| 登出 | clear() | signOut() |
| 角色檢查 | 手動 | requireUserSession(event, { user: { role } }) |
| 部署 | 所有環境 | Workers 需 Hyperdrive |
Token efficiency: Main skill ~300 tokens, each sub-file ~600-800 tokens
development
Pinia official Vue state management library, type-safe and extensible. Use when defining stores, working with state/getters/actions, or implementing store patterns in Vue apps.
development
Pinia Store 架構規範。Use when creating app/stores/**/*.ts files, working with defineStore, managing global state, or building Pinia stores. Always use this skill for store design patterns, naming conventions, and state management architecture.
tools
Push interfaces past conventional limits with technically ambitious implementations. Whether that's a shader, a 60fps virtual table, spring physics on a dialog, or scroll-driven reveals — make users ask "how did they do that?"
content-media
Improve interface performance across loading speed, rendering, animations, images, and bundle size. Makes experiences faster and smoother.