選項

使用 Nuxt 4 建立全端 Vue 應用程式,內容涵蓋伺服器端渲染(SSR)、基於檔案的路由、自動匯入、伺服器路由以及部署。

...展開全部
7
更新時間 2026-09-06

Nuxt 是一個全端 Vue 框架,提供伺服器端渲染、基於檔案的路由、自動導入功能,以及強大的模組系統。它採用 Nitro 作為伺服器引擎,可跨 Node.js、無伺服器及邊緣平台進行通用部署。

本技能基於 Nuxt 4.x,生成日期為 2026-06-22。

Nuxt 4 註:預設的 srcDirapp/ — Vue 應用程式程式碼(app.vue, components/, composables/, pages/、等)位於 app/,而 server/, shared/, public/, modules/, layers/nuxt.config.ts 則保留在專案根目錄下。這些 ~/@ 別名現已指向 app/;請使用 ~~/@@ 作為根目錄。

核心

主題 說明 參考資料
目錄結構 Nuxt 4 app/ srcDir、 shared/, 別名, 規範 核心目錄結構
設定 nuxt.config.ts、app.config.ts、別名、相容性版本、實驗性功能 核心設定
命令列介面 (CLI) 指令 開發伺服器、建置、產生、預覽及實用程式指令 core-cli
路由 基於檔案的路由、動態路由、命名檢視、佈局屬性、中介軟體 core-routing
資料擷取 useFetch、useAsyncData、$fetch、createUseFetch 工廠函式、快取 核心資料擷取
模組 建立與使用 `Nuxt` 模組、`Nuxt` Kit 公用程式 核心模組
部署 透過 Nitro、Vercel、Netlify、Cloudflare 進行平台無關的部署 核心部署

功能

主題 說明 參考
可組合函式自動匯入 Vue/Nuxt 可組合函式、自訂可組合函式、 shared/, useAnnouncer features-composables
元件自動導入 元件命名、延遲載入、初始化策略 功能-元件-自動匯入
內建元件 NuxtLink、NuxtPage、NuxtLayout、NuxtAnnouncer、ClientOnly 等 features-components
狀態管理 useState 可組合函式、支援 SSR 的狀態、Pinia 整合 features-state
伺服器路由 API 路由、伺服器中介軟體、Nitro 伺服器引擎 功能-伺服器

渲染

主題 說明 參考
渲染模式 通用 (SSR)、客戶端 (SPA)、混合渲染、路由規則 渲染模式

最佳實務

主題 說明 參考
資料擷取模式 高效擷取、快取、並行請求、錯誤處理 資料擷取的最佳實務
伺服器端渲染 (SSR) 與資料初始化 避免上下文洩漏、資料初始化不匹配、可組合模式 SSR 最佳實踐

進階

主題 描述 參考資料
透過可重複使用的層擴充應用程式 進階層級
生命週期掛鉤 建置時、執行時與伺服器掛鉤 進階掛鉤
模組開發 使用Nuxt套件、基於鍵的可組合元件及依賴項所建構的可發佈模組 進階模組開發
在 GitHub 上查看
---
name: nuxt
description: Build full-stack Vue applications with Nuxt 4, covering SSR, file-based routing, auto-imports, server routes, and deployment.
---

Nuxt is a full-stack Vue framework that provides server-side rendering, file-based routing, auto-imports, and a powerful module system. It uses Nitro as its server engine for universal deployment across Node.js, serverless, and edge platforms.

> The skill is based on Nuxt 4.x, generated at 2026-06-22.

> **Nuxt 4 note:** the default `srcDir` is `app/` — Vue app code (`app.vue`, `components/`, `composables/`, `pages/`, etc.) lives under `app/`, while `server/`, `shared/`, `public/`, `modules/`, `layers/` and `nuxt.config.ts` stay at the project root. The `~`/`@` aliases now point at `app/`; use `~~`/`@@` for the root.

## Core

| Topic | Description | Reference |
|-------|-------------|-----------|
| Directory Structure | Nuxt 4 `app/` srcDir, `shared/`, aliases, conventions | [core-directory-structure](references/core-directory-structure.md) |
| Configuration | nuxt.config.ts, app.config.ts, aliases, compatibilityVersion, experimental | [core-config](references/core-config.md) |
| CLI Commands | Dev server, build, generate, preview, and utility commands | [core-cli](references/core-cli.md) |
| Routing | File-based routing, dynamic routes, named views, layout props, middleware | [core-routing](references/core-routing.md) |
| Data Fetching | useFetch, useAsyncData, $fetch, createUseFetch factories, caching | [core-data-fetching](references/core-data-fetching.md) |
| Modules | Creating and using Nuxt modules, Nuxt Kit utilities | [core-modules](references/core-modules.md) |
| Deployment | Platform-agnostic deployment with Nitro, Vercel, Netlify, Cloudflare | [core-deployment](references/core-deployment.md) |

## Features

| Topic | Description | Reference |
|-------|-------------|-----------|
| Composables Auto-imports | Vue/Nuxt composables, custom composables, `shared/`, useAnnouncer | [features-composables](references/features-composables.md) |
| Components Auto-imports | Component naming, lazy loading, hydration strategies | [features-components-autoimport](references/features-components-autoimport.md) |
| Built-in Components | NuxtLink, NuxtPage, NuxtLayout, NuxtAnnouncer, ClientOnly, and more | [features-components](references/features-components.md) |
| State Management | useState composable, SSR-friendly state, Pinia integration | [features-state](references/features-state.md) |
| Server Routes | API routes, server middleware, Nitro server engine | [features-server](references/features-server.md) |

## Rendering

| Topic | Description | Reference |
|-------|-------------|-----------|
| Rendering Modes | Universal (SSR), client-side (SPA), hybrid rendering, route rules | [rendering-modes](references/rendering-modes.md) |

## Best Practices

| Topic | Description | Reference |
|-------|-------------|-----------|
| Data Fetching Patterns | Efficient fetching, caching, parallel requests, error handling | [best-practices-data-fetching](references/best-practices-data-fetching.md) |
| SSR & Hydration | Avoiding context leaks, hydration mismatches, composable patterns | [best-practices-ssr](references/best-practices-ssr.md) |

## Advanced

| Topic | Description | Reference |
|-------|-------------|-----------|
| Layers | Extending applications with reusable layers | [advanced-layers](references/advanced-layers.md) |
| Lifecycle Hooks | Build-time, runtime, and server hooks | [advanced-hooks](references/advanced-hooks.md) |
| Module Authoring | Publishable modules with Nuxt Kit, keyed composables, dependencies | [advanced-module-authoring](references/advanced-module-authoring.md) |

所有檔案

0 個檔案

安裝 nuxt

請下載並將技能檔案解壓縮至您的 .claude/skills/ 目錄中。

下載 ZIP

複製儲存庫並將技能檔案複製到您的專案中。

git clone https://github.com/antfu/skills/tree/main/skills/nuxt # Copy SKILL.md to your .claude/skills/ directory

複製 複製
快速設定: 將技能資料夾複製到 .claude/skills/ Claude 會自動偵測並使用該技能
儲存庫 antfu/skills

相關技能

github-code-search
更新時間 2026-06-29
drizzle-orm
更新時間 2026-06-29
clickhouse-io
更新時間 2026-06-29
prisma-client-api
更新時間 2026-06-29
OR