@dxup/nuxt

中文文档
0.5.11发布于 2026/11/05MITTypeScriptESM + CJS构建来源已验证近 30 天下载 948.2万

TypeScript plugin for Nuxt

原始使用文档
文档目录12 节
  1. Installation
  2. Usage
  3. Features
  4. 1. components
  5. 2. importGlob
  6. 3. namedLayoutSlots
  7. 4. nitroRoutes
  8. 5. pageMeta
  9. 6. runtimeConfig
  10. 7. typedPages
  11. 8. unimport
  12. 9. unofficial

@dxup/nuxt

version downloads license

This is a TypeScript plugin that improves Nuxt DX.

[!note] It's now an experimental builtin feature of Nuxt. Please refer to the documentation for more details.

Installation

No installation is required if you are using Nuxt 4.2 or above.

Usage

  1. Have @dxup/unimport installed as a dependency if you haven't enabled the shamefullyHoist option with pnpm workspace.

  2. Add the following to your nuxt.config.ts:

    export default defineNuxtConfig({
      experimental: {
        typescriptPlugin: true,
      },
      dxup: {
        features: {
          // Enable opt-in features
          namedLayoutSlots: true,
        },
      },
    });
    
  3. Run nuxt prepare and restart the tsserver.

Features

1. components

Update references when renaming auto imported component files.

For example, when renaming components/foo/bar.vue to components/foo/baz.vue, all usages of <FooBar /> will be updated to <FooBaz />.

It only works when the dev server is active.

2. importGlob

Go to definition for dynamic imports with glob patterns.

import(`~/assets/${name}.webp`);
//     ^^^^^^^^^^^^^^^^^^^^^^^
import.meta.glob("~/assets/*.webp");
//               ^^^^^^^^^^^^^^^^^

3. namedLayoutSlots

Default: false

Write top-level named slots in your pages:

<!-- layouts/center.vue -->
<template>
  <slot />
  <slot name="side" one="one"/>
</template>
<!-- pages/about.vue -->
<script lang="ts" setup>
  definePageMeta({
    layout: "center",
  });
</script>

<template>
  <template #side="{ one }">
    This "{{ one }}" comes from the layout slot.
    <!--     ^^^ -->
  </template>
  <div>About Page</div>
</template>

And them will be forwarded to the active layout automatically.

The layout can access the slots forwarded by the active page with the auto imported useLayoutSlots composable:

<!-- layouts/center.vue -->
<script lang="ts" setup>
  const slots = useLayoutSlots();
</script>

<template>
  <slot/>
  <aside v-if="slots.side">
    <slot name="side"/>
  </aside>
</template>

4. nitroRoutes

Go to definition for nitro routes in data fetching methods.

useFetch("/api/foo");
//       ^^^^^^^^^^
// Also `$fetch` and `useLazyFetch`.

It will fallback to resolve the URL from your public directory when no nitro routes match.

5. pageMeta

Go to definition for page metadata.

definePageMeta({
  layout: "admin",
  //      ^^^^^^^
  middleware: ["auth"],
  //           ^^^^^^
});

6. runtimeConfig

Go to definition for runtime config.

<template>
  {{ $config.public.domain }}
  <!--              ^^^^^^ -->
</template>

7. typedPages

Go to definition for typed pages.

<template>
  <nuxt-link :to="{ name: `about` }"/>
  <!--                    ^^^^^^^ -->
</template>

It can be triggered on the name property of an object literal constrained by the RouteLocationRaw type.

8. unimport

Please refer to the @dxup/unimport package for more details.

9. unofficial

Find references for SFC on <template>.

....<template>
<!-- ^^^^^^^^ -->
</template>

版本与发布记录

@dxup/nuxt 共发布 27 个版本,首次发布于 2025/09/25;过去 12 个月发布了 17 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.5.11latest2026/11/058 天前
0.5.102026/08/222 个月前
0.5.92026/08/202 个月前
0.5.82026/08/172 个月前
0.5.72026/08/142 个月前
0.5.62026/08/033 个月前

关于 @dxup/nuxt 的常见问题

@dxup/nuxt 是什么?

TypeScript plugin for Nuxt

如何安装 @dxup/nuxt?

在项目目录运行 npm install @dxup/nuxt,或使用 pnpm add / yarn add / bun add。

@dxup/nuxt 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dxup/nuxt 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@dxup/nuxt 可以商用吗?

@dxup/nuxt 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@dxup/nuxt 的下载量有多少?

根据 npm 官方下载统计,@dxup/nuxt 在 2026/10/13 – 2026/11/11 这 30 天内被下载 9,481,838 次,日均约 316,061 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dxup/nuxt 还在维护吗?

最新版本 0.5.11 发布于 2026/11/05(8 天前);至今共发布 27 个版本,其中过去 12 个月发布了 17 个;首次发布于 2025/09/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。