clerk-nuxt-patterns
This skill teaches agents how to implement authentication in Nuxt 3 applications using the Clerk SDK.
Identity proven by GitHub's verified organisation badge (clerk)
- Agents
- Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode
- License
- MIT (permissive)
- Pin
- a02dbd2pinned Oct 9, 2026
- Context cost
- about 710 tokenswhen the skill loads
- GitHub stars
- 86on clerk/skills
- Scripts
- 1 script
What it does
“Nuxt 3 auth patterns with @clerk/nuxt - middleware, composables, server API routes, SSR. Triggers on: Nuxt auth, useAuth composable, clerkMiddleware Nuxt, server API Clerk, Nuxt route protection.”
Generated summary from the skill's own text
This skill teaches agents how to implement authentication in Nuxt 3 applications using the Clerk SDK. It covers route protection with middleware, auth composables for components, server-side auth in Nitro routes, and SSR-safe patterns to avoid common hydration issues.
When to use it
- Building Nuxt 3 apps requiring user authentication and route protection
- Implementing org-aware auth with role-based access control in Nuxt
- Adding server-side auth checks to Nuxt API routes and server handlers
- Handling auth state in client and server contexts without hydration mismatches
When not to
- Projects not using Nuxt 3 or a different auth provider
- When custom authentication logic outside Clerk ecosystem is preferred
Install
These commands install from the publisher's repository and need no account.
skills CLI
npx skills add clerk/skills --skill clerk-nuxt-patternsInstalls from the repository's default branch, which may have changed since the commit we checked.
GitHub CLI 2.90 or later
gh skill install clerk/skills clerk-nuxt-patterns@a02dbd2a933b8929525129a6cb9dcf6ed66d0adfInstalls the commit we checked (a02dbd2).
Copy by hand
Download the folder at a02dbd2 and put it in .claude/skills/clerk-nuxt-patterns for Claude Code and in .agents/skills/clerk-nuxt-patterns for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode.
Copy for your agent
A prompt for any coding agent. It installs this skill from GitHub at the pinned commit, copies the files as they are, and runs nothing unless you ask.
Prompt
Install the agent skill "clerk-nuxt-patterns" by Clerk. Source, pinned to commit a02dbd2a933b8929525129a6cb9dcf6ed66d0adf: https://github.com/clerk/skills/tree/a02dbd2a933b8929525129a6cb9dcf6ed66d0adf/skills/clerk-nuxt-patterns 1. Download that folder at exactly this commit. Do not use the default branch. 2. Copy every file unchanged, keeping the folder structure, into .claude/skills/clerk-nuxt-patterns/ for Claude Code and .agents/skills/clerk-nuxt-patterns/ for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode. Create the folders if they do not exist. 3. Do not edit the files, and do not run any script in the folder unless I ask you to. 4. When you are done, list the files you copied and where you put them. Listing and checks: https://www.agentnative.dev/skills/clerk/clerk-nuxt-patterns
SKILL.md at the pin
---
name: clerk-nuxt-patterns
description: 'Nuxt 3 auth patterns with @clerk/nuxt - middleware, composables, server
API routes, SSR. Triggers on: Nuxt auth, useAuth composable, clerkMiddleware Nuxt,
server API Clerk, Nuxt route protection.'
license: MIT
allowed-tools: WebFetch
metadata:
author: clerk
version: 1.0.0
---
# Nuxt Patterns
## What Do You Need?
| Task | Reference |
|------|-----------|
| Protect routes with middleware | references/nuxt-middleware.md |
| Auth in server API routes (Nitro) | references/server-api-routes.md |
| useAuth / useUser in components | references/composables.md |
| SSR-safe auth patterns | references/ssr-auth.md |
## References
| Reference | Description |
|-----------|-------------|
| `references/nuxt-middleware.md` | Route protection, clerkMiddleware() |
| `references/server-api-routes.md` | Nitro server route auth |
| `references/composables.md` | useAuth, useUser, useClerk |
| `references/ssr-auth.md` | SSR hydration, server vs client |
## Setup
```
npm install @clerk/nuxt
```
`.env`:
```
NUXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_...
NUXT_CLERK_SECRET_KEY=sk_...
```
`nuxt.config.ts`:
```typescript
export default defineNuxtConfig({
modules: ['@clerk/nuxt'],
})
```
This single line auto-configures middleware, plugins, and component auto-imports.
## Mental Model
`@clerk/nuxt` auto-imports all Clerk components and composables — no explicit imports needed in `<script setup>`.
- **Composables** (`useAuth`, `useUser`) — client-side reactive, inside `<script setup>`
- **Server routes** (`clerkClient`) — Nitro server routes, `event.context.auth`
- **Middleware** (`clerkMiddleware`) — auto-registered, use `auth().protect()` to lock routes
## Minimal Pattern
```vue
<!-- pages/dashboard.vue -->
<script setup lang="ts">
definePageMeta({ middleware: 'auth' })
const { userId } = useAuth()
</script>
<template>
<Show when="signed-in">
<p>Hello {{ userId }}</p>
</Show>
</template>
```
> `definePageMeta({ middleware: 'auth' })` uses the built-in auth middleware from `@clerk/nuxt`.
## Common Pitfalls
| Symptom | Cause | Fix |
|---------|-------|-----|
| Composables return `undefined` on server | useAuth is client-only | Use `event.context.auth` in server routes |
| Route not protected | Missing `middleware: 'auth'` meta | Add `definePageMeta({ middleware: 'auth' })` |
| `clerkClient` not available | Wrong import path | Import from `@clerk/nuxt/server` |
| Hydration mismatch | Rendering auth state before mounted | Wrap in `<ClientOnly>` or check `isLoaded` |
| Env vars not picked up | Wrong prefix | Nuxt requires `NUXT_PUBLIC_` for public, `NUXT_` for server |
## Org-Aware Pattern
```vue
<script setup lang="ts">
const { orgId, orgRole } = useAuth()
</script>
<template>
<div v-if="orgId">
<p>Org: {{ orgId }}</p>
<p v-if="orgRole === 'org:admin'">Admin panel</p>
</div>
<div v-else>
<OrganizationSwitcher />
</div>
</template>
```
## See Also
- `clerk-setup` - Initial Clerk install
- `clerk-custom-ui` - Custom flows & appearance
- `clerk-orgs` - B2B organizations
## Docs
[Nuxt SDK](https://clerk.com/docs/nuxt/getting-started/quickstart)
From clerk/skills at a02dbd2, shown as plain text under its license: MIT (permissive). The license text is in skills/clerk-nuxt-patterns/SKILL.md.
View SKILL.md on GitHub at a02dbd2Files
- SKILL.md3.2 KB · 9091d7cff9f4
- evals/
- evals.json6.6 KB · 8d62eb0821b5
- references/
- composables.md1.9 KB · 03bc36488935
- nuxt-middleware.md1.5 KB · fe309795d51a
- server-api-routes.md1.6 KB · 71915b34ac02
- ssr-auth.md2.2 KB · b2f5115054f3
- templates/
- nuxt-basic-auth/
- app.vue267 B · 8cb50feb0938
- nuxt.config.ts65 B · 85064dc1fe40
- package.json195 B · cf2c10cc112a
9 files, 18 KB in total. Each file has a sha256 in the pin's manifest; the first 12 characters are shown.
Skill folder on GitHub at a02dbd2More from Clerk
audit-clerk-skill
Audits the bundled clerk-cli skill against the Clerk CLI source repository, comparing commands, flags, and agent-mode behavior to detect drift, gaps, and…
Claude Code · about 1.9K tokens · pinned 6 days ago
audit-expo-skill
Audits the clerk-expo skill against the @clerk/expo SDK source and clerk-docs to detect API drift, missing coverage, and stale claims.
Claude Code · about 2.2K tokens · pinned 6 days ago
clerk
This skill routes Clerk authentication tasks to specialized sub-skills based on the user's specific need, such as framework setup, CLI operations, custom UI…
Claude Code, Codex, Cursor +4 · about 1.4K tokens · pinned 6 days ago
clerk-android
This skill implements Clerk authentication in native Android apps written in Kotlin and Jetpack Compose by following the clerk-android SDK patterns and…
Claude Code, Codex, Cursor +4 · about 2K tokens · pinned 6 days ago
clerk-astro-patterns
This skill teaches the agent to integrate Clerk authentication into Astro applications using middleware, SSR pages, island components, and API routes.
Contains scripts
Claude Code, Codex, Cursor +3 · about 850 tokens · pinned 6 days ago
clerk-billing
Clerk Billing enables subscription management in SaaS apps by rendering pricing tables and checkout drawers, configuring plans with feature entitlements, and…
Claude Code, Codex, Cursor +4 · about 4.9K tokens · pinned 6 days ago
Related in Backend and APIs
clerk-nextjs-patterns
This skill teaches advanced Next.js patterns for protecting routes, Server Actions, and API endpoints with Clerk authentication.
by ClerkOfficial publisher
Contains scripts
Claude Code, Codex, Cursor +3 · about 2.1K tokens · pinned 6 days ago
clerk-setup
This skill sets up Clerk authentication in new or existing projects using the Clerk CLI.
by ClerkOfficial publisher
Claude Code, Codex, Cursor +4 · about 2.9K tokens · pinned 6 days ago
clerk-tanstack-patterns
This skill provides authentication patterns for TanStack React Start applications using Clerk.
by ClerkOfficial publisher
Contains scripts
Claude Code, Codex, Cursor +3 · about 860 tokens · pinned 6 days ago
nvflare-orient
Routes NVFLARE requests to appropriate downstream skills based on user intent and preliminary source inspection findings.
by NVIDIAOfficial publisher
Claude Code, Codex, Cursor +4 · about 600 tokens · pinned 6 days ago
cloudflare-email-service
This skill enables agents to send transactional emails and route incoming emails using Cloudflare's Email Service platform.
by CloudflareOfficial publisher
Claude Code, Codex, Cursor +4 · about 1.6K tokens · pinned 6 days ago
durable-objects
Build and debug Cloudflare Durable Objects applications for stateful coordination and persistent storage on the edge.
by CloudflareOfficial publisher
Claude Code, Codex, Cursor +4 · about 1.5K tokens · pinned 6 days ago