Nuxtjs Vue Typescript

mindrally/skills/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 从公开仓库中收录这些内容。

举报或申请下架