secondsky/claude-skills / plugins/nuxt-v5/skills/nuxt-data
nuxt-data
VerifiedNuxt 5 data management with useFetch, useAsyncData, useState, and Pinia. Use when creating composables, fetching data, managing state, or debugging reactive/SSR data issues.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 10.2 KB |
| references/composables.md | markdown | 16.0 KB |
| references/data-fetching.md | markdown | 15.9 KB |
| templates/composables/useAuth.ts | script | 3.0 KB |
templates/composables/useAuth.ts
View on GitHub// Authentication composable example
interface User {
id: string
email: string
name: string
role: 'admin' | 'user'
}
interface AuthState {
user: User | null
isAuthenticated: boolean
isLoading: boolean
error: string | null
sessionError: string | null // Track session check failures
lastSessionCheck: number | null // Track when last check occurred
}
export const useAuth = () => {
// Shared state across all components
const state = useState<AuthState>('auth', () => ({
user: null,
isAuthenticated: false,
isLoading: false,
error: null,
sessionError: null,
lastSessionCheck: null
}))
// Login
const login = async (email: string, password: string) => {
state.value.isLoading = true
state.value.error = null
try {
const data = await $fetch<{ user: User }>('/api/auth/login', {
method: 'POST',
body: { email, password }
})
state.value.user = data.user
state.value.isAuthenticated = true
// Navigate to dashboard
await navigateTo('/dashboard')
} catch (err) {
state.value.error = err instanceof Error ? err.message : 'Login failed'
throw err
} finally {
state.value.isLoading = false
}
}
// Logout
const logout = async () => {
try {
await $fetch('/api/auth/logout', { method: 'POST' })
} catch (err) {
// Log API failure but still proceed with local logout
console.error('Logout API failed:', err)
} finally {
state.value.user = null
state.value.isAuthenticated = false
await navigateTo('/login')
}
}
// Check session (call on app mount)
const checkSession = async () => {
// Only run on client
if (import.meta.server) return
try {
const data = await $fetch<{ user?: User }>('/api/auth/session')
if (data?.user) {
state.value.user = data.user
state.value.isAuthenticated = true
} else {
state.value.user = null
state.value.isAuthenticated = false
}
state.value.sessionError = null
state.value.lastSessionCheck = Date.now()
} catch (err) {
console.error('Session check failed:', err)
// Surface error to UI with user-friendly message
state.value.sessionError = 'Unable to verify session. Please check your connection.'
state.value.lastSessionCheck = Date.now()
}
}
return {
// State (readonly)
user: computed(() => state.value.user),
isAuthenticated: computed(() => state.value.isAuthenticated),
isLoading: computed(() => state.value.isLoading),
error: computed(() => state.value.error),
sessionError: computed(() => state.value.sessionError),
lastSessionCheck: computed(() => state.value.lastSessionCheck),
// Methods
login,
logout,
checkSession
}
}
// Usage in components:
// const { sessionError, lastSessionCheck } = useAuth()
//
// Show banner when session checks fail:
// <div v-if="sessionError" class="error-banner">{{ sessionError }}</div>
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |