Nuxtjs Vue Typescript

作者 mindrally97184105b5da無授權條款269 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫5 週前更新

Best practices for building Nuxt 3 and Vue 3 applications with TypeScript, the Composition API, and Tailwind CSS. Use when structuring Nuxt/Vue projects, writing composables, typing components and props, wiring up server routes and plugins, or optimizing Nuxt builds and Web Vitals.

AI 產生的概覽

以 TypeScript、組合式 API 與 Tailwind CSS 建構 Nuxt 3 和 Vue 3 應用程式的實務指南。

功能
提供一套以 TypeScript 撰寫的 Nuxt 3 與 Vue 3 專案的程式碼規範與最佳實務。內容涵蓋檔案與命名結構、TypeScript 型別用法、組合式 API、使用 Shadcn Vue、Radix Vue 與 Tailwind 的介面樣式、效能與 Web Vitals 最佳化,以及 Nuxt 專屬功能,例如自動匯入、伺服器路由、版面配置與資料擷取。它產出的是指導建議,而非程式碼成品。
適用情境
適用於規劃 Nuxt 或 Vue 專案結構、撰寫組合式函式、為元件與 props 加上型別、串接伺服器路由與外掛,或最佳化 Nuxt 建置與 Web Vitals 的情境。
執行需求
除代理本身外無其他需求;此技能僅包含說明文件,沒有指令碼、套件、憑證或網路存取需求。

NuxtJS Vue TypeScript Development

Guidelines for building Nuxt 3 and Vue 3 applications with TypeScript, Shadcn Vue, Radix Vue, VueUse, and Tailwind.

Code Style and Structure

  • Write concise, technical TypeScript with accurate examples
  • Employ composition API with declarative patterns; avoid options API
  • Favor iteration and modularity over code duplication
  • Use descriptive variable names with auxiliary verbs (isLoading, hasError)
  • Organize files: exported component, composables, helpers, static content, types
  • Keep component boundaries clear — a component should own one piece of UI/behavior; extract composables when logic grows beyond simple template glue

Naming Conventions

  • Directories: lowercase with dashes (components/auth-wizard)
  • Components: PascalCase (AuthWizard.vue)
  • Composables: camelCase (useAuthState.ts)

TypeScript Usage

  • Utilize TypeScript throughout; prefer types over interfaces, but use interfaces where you expect a shape to be extended or implemented (e.g. component prop contracts)
  • Keep shared types close to the feature that owns them; only promote a type to a shared types/ directory once a second feature needs it
  • Avoid enums; use const objects instead
  • Leverage Vue 3 with TypeScript, defineComponent, and PropType

Syntax and Formatting

  • Use arrow functions for methods and computed properties
  • Minimize curly braces in conditionals
  • Employ template syntax for declarative rendering

UI and Styling

  • Implement Shadcn Vue, Radix Vue, and Tailwind
  • Design responsively with mobile-first Tailwind approach
  • Keep Tailwind usage accessible and consistent with the project's design system rather than one-off utility soup

Performance

  • Leverage Nuxt's built-in optimizations
  • Use Suspense for async components
  • Implement lazy loading for routes and components
  • Optimize images: WebP format, size data, lazy loading
  • Review bundle size periodically (nuxi analyze) and use dynamic import() for heavy, rarely-used components

Key Conventions

  • VueUse for common composables — reach for them where they simplify reactivity, but avoid ones that hide state transitions you need to reason about explicitly
  • Pinia for state management
  • Optimize Web Vitals (LCP, CLS, FID)
  • Use Nuxt's auto-imports feature

Nuxt-Specific Guidelines

  • Follow Nuxt 3 directory structure (pages/, components/, composables/, layouts/, plugins/, server/)
  • Leverage auto-imports, file-based routing, server routes, plugins
  • Use layouts (layouts/default.vue, <NuxtLayout>) to share page chrome instead of duplicating it per page
  • Use server/api/ routes (Nitro) for server-side endpoints, and useRuntimeConfig() for environment-specific config instead of hardcoding values
  • Use useFetch and useAsyncData for data fetching
  • Implement SEO with useHead and useSeoMeta

Vue 3 Composition API Best Practices

  • Use <script setup> syntax
  • Leverage ref, reactive, and computed
  • Use provide/inject for dependency injection
  • Create custom composables for reusable logic

來源與署名

來源:mindrally/skills位於nuxtjs-vue-typescript提交9718410

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架