---
title: "Nuxt Kit"
description: "@nuxt/kit 为模块作者提供功能。"
canonical_url: "https://nuxt.zhcndoc.com/docs/4.x/guide/going-further/kit"
---
# Nuxt Kit

> @nuxt/kit 为模块作者提供功能。

Nuxt Kit 提供可组合的实用工具，让您可以轻松地与 [Nuxt Hooks](https://nuxt.zhcndoc.com/docs/4.x/api/advanced/hooks)、[Nuxt Interface](https://nuxt.zhcndoc.com/docs/4.x/guide/going-further/internals#the-nuxt-interface) 交互并开发 [Nuxt 模块](https://nuxt.zhcndoc.com/docs/4.x/guide/modules)。

<read-more to="https://nuxt.zhcndoc.com/docs/4.x/api/kit">

了解所有 Nuxt Kit 实用工具。

</read-more>

## 使用

### 安装依赖

您可以通过将其添加到 `package.json` 的 `dependencies` 部分来安装最新的 Nuxt Kit。但是，即使 Nuxt 已经安装了该包，也建议始终显式安装 `@nuxt/kit` 包。

<note>

`@nuxt/kit` 和 `@nuxt/schema` 是 Nuxt 的关键依赖。如果您单独安装它们，请确保 `@nuxt/kit` 和 `@nuxt/schema` 的版本与 `nuxt` 版本相等或更高，以避免出现意外行为。

</note>

```json [package.json]
{
  "dependencies": {
    "@nuxt/kit": "npm:@nuxt/kit-nightly@latest"
  }
}
```

### 导入 Kit 工具

```ts [test.mjs]
import { useNuxt } from '@nuxt/kit'
```

<read-more to="https://nuxt.zhcndoc.com/docs/4.x/api/kit">



</read-more>

<note>

Nuxt Kit 实用工具仅在模块中可用，不应在运行时（组件、Vue 组合式函数、页面、插件或服务器路由）中导入。

</note>

Nuxt Kit 是一个[仅支持 esm 的包](https://nuxt.zhcndoc.com/docs/4.x/guide/concepts/esm)，这意味着您**不能**使用 `require('@nuxt/kit')`。作为一种变通方法，请在 CommonJS 上下文中使用动态导入：

```ts [test.cjs]
// 这是无效的！
// const kit = require('@nuxt/kit')
async function main () {
  const kit = await import('@nuxt/kit')
}
main()
```


## Sitemap

See the full [sitemap](https://nuxt.zhcndoc.com/sitemap.md) for all pages.
