nuxt-skills
2
总安装量
1
周安装量
#68434
全站排名
安装命令
npx skills add https://github.com/yulei-chen/ssaw --skill nuxt-skills
Agent 安装分布
cursor
1
Skill 文档
Nuxt Skills
Project layout
- Source directory: Prefer
srcDir: 'app'soapp/holds pages, components, composables, layouts, middleware. Reference as~/(e.g.~/components/,~/composables/). - Pages:
app/pages/*.vueâ file-based routing. UsedefinePageMeta({ middleware: 'auth' })for route-level middleware. - Layouts:
app/layouts/default.vue(or named). Use<NuxtLayout>orapp.vueto wrap content. - Components:
app/components/â auto-imported; use PascalCase names in templates.
Composables
- Location:
app/composables/*.tsâ auto-imported. Export functions nameduseXxx. - Pattern: Accept
Ref<T> | Tfor flexibility; normalize withtypeof x === 'string' ? ref(x) : xwhen needed. - Data fetching: Prefer
useAsyncDatawith a unique key (e.g.time-blocks-${uid}-${day}), async fetcher, andwatchfor reactive params. Return{ data, refresh, pending }.
Data and server
- useAsyncData: Use for client-side fetches that depend on reactive state. Key must be unique per logical query; include reactive identifiers in the key.
- useFetch: Use when the URL/params are the only input; for Supabase or custom clients,
useAsyncData+ client call is usually clearer. - Lazy: Prefer non-lazy by default for above-the-fold data; use
lazy: truewhen appropriate for secondary content.
Auth and routing
- Supabase user:
useSupabaseUser()in middleware or setup. Redirect withnavigateTo('/login')when unauthenticated. - Middleware:
app/middleware/*.tsâ export defaultdefineNuxtRouteMiddleware((to, from) => { ... }). Name file for usage (e.g.auth.tsâmiddleware: 'auth').
Config (nuxt.config.ts)
- defineNuxtConfig: Set
compatibilityDate,srcDir,modules, and module options (e.g.supabase,pwa,app.head). - Aliases:
~and@typically point tosrcDir; use~/for app code.
Conventions
- Use
<script setup lang="ts">in Vue SFCs. - Prefer composables for shared state and side effects; keep pages thin and delegate to components and composables.
- Use
ref/computed/watchfrom Vue; no need to import when using auto-imports (Nuxt provides them).