Index of every page on this site: llms.txt
All skills
antfu avatar

/nuxt

@7de210b official
by Anthony Fuantfu/skills6k stars
342
Run it yourself

Nuxt full-stack Vue framework with SSR, auto-imports, and file-based routing. Use when working with Nuxt apps, server routes, useFetch, middleware, or hybrid rendering.

Use this Skill: https://skilld.dev/gh/antfu/skills/nuxt

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesfeatures-components-autoimport.md

≈1.5k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Components Auto-imports

Nuxt automatically imports Vue components from app/components/ directory.

Basic Auto-imports

components/
├── Button.vue         → <Button />
├── Card.vue           → <Card />
└── AppHeader.vue      → <AppHeader />
<template>
  <!-- No imports needed -->
  <AppHeader />
  <Card>
    <Button>Click me</Button>
  </Card>
</template>

Naming Conventions

Nested Directory Names

Component names include directory path:

components/
├── base/
│   └── Button.vue       → <BaseButton />
├── form/
│   ├── Input.vue        → <FormInput />
│   └── Select.vue       → <FormSelect />
└── ui/
    └── modal/
        └── Dialog.vue   → <UiModalDialog />

Disable Path Prefix

// nuxt.config.ts
export default defineNuxtConfig({
  components: [
    {
      path: '~/components',
      pathPrefix: false, // Use filename only
    },
  ],
})

With pathPrefix: false:

components/base/Button.vue → <Button />

Grouping Directories

Wrap a directory name in parentheses to group files without affecting the component name:

components/base/(foo)/Button.vue → <BaseButton />

pattern / ignore Globs

Each components dir entry accepts pattern and ignore globs to scan non-standard layouts (e.g. domain-driven structure). When pattern is set, the extensions option is ignored:

export default defineNuxtConfig({
  components: [
    // ~/domains/blog/components/PostCard.vue => <PostCard />
    { path: '~/domains', pattern: '*/components/**', pathPrefix: false },
  ],
})

Lazy Loading

Prefix with Lazy for dynamic imports:

<script setup lang="ts">
const showChart = ref(false)
</script>

<template>
  <!-- Component code loaded only when rendered -->
  <LazyHeavyChart v-if="showChart" />
  <button @click="showChart = true">Show Chart</button>
</template>

Benefits:

  • Reduces initial bundle size
  • Code-splits component into separate chunk
  • Loads on-demand

Lazy Hydration Strategies

Control when lazy components become interactive:

hydrate-on-visible

Hydrate when component enters viewport:

<template>
  <LazyComments hydrate-on-visible />
</template>

hydrate-on-idle

Hydrate when browser is idle:

<template>
  <LazyAnalytics hydrate-on-idle />
</template>

hydrate-on-interaction

Hydrate on user interaction:

<template>
  <!-- Hydrates on click, focus, or pointerenter -->
  <LazyDropdown hydrate-on-interaction />

  <!-- Specific event -->
  <LazyTooltip hydrate-on-interaction="mouseover" />
</template>

hydrate-on-media-query

Hydrate when media query matches:

<template>
  <LazyMobileMenu hydrate-on-media-query="(max-width: 768px)" />
</template>

hydrate-after

Hydrate after delay (milliseconds):

<template>
  <LazyAds :hydrate-after="3000" />
</template>

hydrate-when

Hydrate on condition:

<script setup lang="ts">
const isReady = ref(false)
</script>

<template>
  <LazyEditor :hydrate-when="isReady" />
</template>

hydrate-never

Never hydrate (static only):

<template>
  <LazyStaticFooter hydrate-never />
</template>

Hydration Event

<template>
  <LazyChart hydrate-on-visible @hydrated="onChartReady" />
</template>

<script setup>
function onChartReady() {
  console.log('Chart is now interactive')
}
</script>

Client/Server Components

Client-only (.client.vue)

components/
└── BrowserChart.client.vue
<template>
  <!-- Only rendered in browser -->
  <BrowserChart />
</template>

Server-only (.server.vue)

components/
└── ServerMarkdown.server.vue
<template>
  <!-- Rendered on server, not hydrated -->
  <ServerMarkdown :content="markdown" />
</template>

Requires experimental flag:

// nuxt.config.ts
export default defineNuxtConfig({
  experimental: {
    componentIslands: true,
  },
})

Paired Components

components/
├── Comments.client.vue  # Browser version
└── Comments.server.vue  # SSR version

Server version renders during SSR, client version takes over after hydration.

Dynamic Components

<script setup lang="ts">
import { SomeComponent } from '#components'

const dynamicComponent = resolveComponent('MyButton')
</script>

<template>
  <component :is="dynamicComponent" />
  <component :is="SomeComponent" />
</template>

Direct Imports

Bypass auto-imports when needed:

<script setup lang="ts">
import { LazyMountainsList, NuxtLink } from '#components'
</script>

Custom Directories

// nuxt.config.ts
export default defineNuxtConfig({
  components: [
    { path: '~/components/ui', prefix: 'Ui' },
    { path: '~/components/forms', prefix: 'Form' },
    '~/components', // Default, should come last
  ],
})

Global Components

Register globally (creates async chunks):

// nuxt.config.ts
export default defineNuxtConfig({
  components: {
    global: true,
    dirs: ['~/components'],
  },
})

Or use .global.vue suffix:

components/
└── Icon.global.vue  → Available globally

Disabling Component Auto-imports

// nuxt.config.ts
export default defineNuxtConfig({
  components: {
    dirs: [], // Disable auto-imports
  },
})

Library Authors

Register components from npm package:

// my-ui-lib/nuxt.ts
import { addComponentsDir, createResolver, defineNuxtModule } from '@nuxt/kit'

export default defineNuxtModule({
  setup() {
    const resolver = createResolver(import.meta.url)

    addComponentsDir({
      path: resolver.resolve('./components'),
      prefix: 'MyUi',
    })
  },
})
<!-- Source references: - https://nuxt.com/docs/directory-structure/app/components - https://nuxt.com/docs/guide/concepts/auto-imports#auto-imported-components -->

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts3d5 checks · Risk SAFE
  • Gen Agent Trust Hub3d

    This skill is a collection of documentation and reference materials for the Nuxt framework (version 5). It contains technical guides on routing, configuration, data fetching, and deployment, intended to assist an AI agent in working with Nuxt projects. No security risks were identified.

  • Socket3d

    No alerts

  • Snyk3d

    Risk: LOW · No issues

  • Runlayer8mo

    3/20 files flagged

  • ZeroLeaks6mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 7de210b. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last week.

Activeupdated last month
Other metadata
metadata
{
  "author": "Anthony Fu",
  "version": "2026.9.25",
  "source": "Generated from https://github.com/nuxt/nuxt, scripts located at https://github.com/antfu/skills"
}
  • Nuxt
  • Vue
  • ssr
  • full-stack
  • file-based-routing
  • nitro
  • auto-imports
  • server-routes
  • composables
  • state-management

README badge

README badge for antfu/skills/nuxt

This skill provides comprehensive guidance on Nuxt 3, a full-stack Vue framework with server-side rendering, file-based routing, auto-imports, and Nitro-powered server deployment. It covers directory structure, configuration, routing, data fetching, state management, server routes, rendering modes, and module authoring across core, feature, and advanced sections.

Generated from the current SKILL.md.

Does this skill cover Nuxt 2?
No. This skill is based on Nuxt 3.x, generated at 2026-01-28.
What server runtime does Nuxt use?
Nuxt uses Nitro as its server engine, which supports universal deployment across Node.js, serverless, and edge platforms.
Does this skill cover server routes and API endpoints?
Yes. The skill includes guidance on server routes, API routes, server middleware, and the Nitro server engine.
What rendering modes are supported?
The skill covers universal (SSR), client-side (SPA), hybrid rendering, and route rules for controlling how pages are rendered.
Does this skill explain state management?
Yes. It covers the useState composable, SSR-friendly state patterns, and Pinia integration.

Generated from the current SKILL.md. These answers refresh after source changes.