Skip to content
Back to skills

Nuxt Auth Utils

ASecurity

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.

  • 44 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 5, 2026
developmentgogitapidatabase

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned September 5, 2026

npx -y skills add Charles5277/nuxt-supabase-starter --skill nuxt-auth-utils --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Nuxt Auth Utils?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Nuxt Auth Utils
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/charles5277-nuxt-auth-utils/badge)](https://www.skillsdirectory.com/skills/charles5277-nuxt-auth-utils)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: nuxt-auth-utils
description: 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.
---

# Nuxt Auth Utils

Cookie-based authentication module for Nuxt. No database required for session storage — sessions are encrypted and stored in cookies.

## When to Use

- Installing/configuring `nuxt-auth-utils`
- Implementing OAuth login flows (Google, GitHub, etc.)
- Protecting routes (client and server)
- Accessing user session in API routes
- Setting up session types

**For Nuxt patterns:** use `nuxt` skill
**For better-auth (DB-based auth):** use `nuxt-better-auth` skill

## Available Guidance

| File                                                       | Topics                                                             |
| ---------------------------------------------------------- | ------------------------------------------------------------------ |
| **[references/client-auth.md](references/client-auth.md)** | useUserSession, OAuth login, logout, session state                 |
| **[references/server-auth.md](references/server-auth.md)** | requireUserSession, getUserSession, setUserSession, OAuth handlers |

## Loading Files

- [ ] [references/client-auth.md](references/client-auth.md) - if building login/logout flows
- [ ] [references/server-auth.md](references/server-auth.md) - if protecting API routes or setting up OAuth handlers

**DO NOT load all files at once.** Load only what's relevant to your current task.

## Key Concepts

| 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'`      |

## Quick Reference

```ts
// Client: useUserSession()
const { user, loggedIn, clear } = useUserSession()
```

```ts
// 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, '/')
  },
})
```

```ts
// Server: protect API route
const { user } = await requireUserSession(event)
```

## vs better-auth

|              | nuxt-auth-utils | better-auth                                     |
| ------------ | --------------- | ----------------------------------------------- |
| Session 儲存 | Cookie(無 DB) | Database                                        |
| 登入方式     | OAuth only      | Email/Password + OAuth                          |
| 登出         | `clear()`       | `signOut()`                                     |
| 角色檢查     | 手動            | `requireUserSession(event, { user: { role } })` |
| 部署         | 所有環境        | Workers 需 Hyperdrive                           |

## Resources

- [nuxt-auth-utils Docs](https://github.com/atinux/nuxt-auth-utils)

---

_Token efficiency: Main skill ~300 tokens, each sub-file ~600-800 tokens_

Files in this skill

  • SKILL.md3.6 KB
  • references/client-auth.md1.6 KB
  • references/server-auth.md3.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.