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.

referencescore-config.md

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

Nuxt Configuration

Nuxt uses configuration files to customize application behavior. The main configuration options are nuxt.config.ts for build-time settings and app.config.ts for runtime settings.

nuxt.config.ts

The main configuration file at the root of your project:

// nuxt.config.ts
export default defineNuxtConfig({
  // Configuration options
  devtools: { enabled: true },
  modules: ['@nuxt/ui'],
})

Path Aliases

The default srcDir is app/, so path aliases resolve as:

Alias Resolves to
~ / @ <rootDir>/app
~~ / @@ <rootDir> (project root)
#shared <rootDir>/shared
#server <rootDir>/server

Reference root-level paths (modules, server handlers) with ~~ or #server:

export default defineNuxtConfig({
  modules: ['~~/custom-modules/awesome.js'], // relative to rootDir
  serverHandlers: [
    { route: '/foo/**', handler: '#server/foohandler.ts' },
  ],
})

nuxt.config Loading (Nuxt 5: no more jiti)

Nuxt 5 no longer bundles jiti. nuxt.config.ts, files in modules/, and layer configs are loaded by the Node runtime directly (requires Node 22.19/24.11+, which strip types natively). Two consequences:

  • Relative imports in these files need an explicit extension — write ./build/plugin.ts, not ./build/plugin (TS reports TS2835). Bare package imports are unaffected.
  • Use erasable TypeScript only in config/module files — no enum, namespace, constructor parameter properties, or decorators (TS reports TS1294).

App and shared/ code go through Vite and are unaffected. Published layers/modules must ship compiled JS (a shipped config as nuxt.config.mjs). Install jiti (-D) to restore the old fallback behavior; a nuxt.schema file always needs it.

Compatibility Version

Nuxt 5 behavior is now the default. future.compatibilityVersion is mostly historical — Nuxt 4 code paths that were opt-in are now unconditional. Individual behaviors are restored via specific experimental/config options (see each section below and the upgrade notes).

Environment Overrides

Configure environment-specific settings:

export default defineNuxtConfig({
  $production: {
    routeRules: {
      '/**': { isr: true },
    },
  },
  $development: {
    // Development-specific config
  },
  $env: {
    staging: {
      // Staging environment config
    },
  },
})

Use --envName flag to select environment: nuxt build --envName staging

Runtime Config

For values that need to be overridden via environment variables:

// nuxt.config.ts
export default defineNuxtConfig({
  runtimeConfig: {
    // Server-only keys
    apiSecret: '123',
    // Keys within public are exposed to client
    public: {
      apiBase: '/api',
    },
  },
})

Override with environment variables:

# .env
NUXT_API_SECRET=api_secret_token
NUXT_PUBLIC_API_BASE=https://api.example.com

Access in components/composables:

<script setup lang="ts">
const config = useRuntimeConfig()
// Server: config.apiSecret, config.public.apiBase
// Client: config.public.apiBase only
</script>

App Config

For public tokens determined at build time (not overridable via env vars):

// app/app.config.ts
export default defineAppConfig({
  title: 'Hello Nuxt',
  theme: {
    dark: true,
    colors: {
      primary: '#ff0000',
    },
  },
})

Access in components:

<script setup lang="ts">
const appConfig = useAppConfig()
</script>

runtimeConfig vs app.config

Feature runtimeConfig app.config
Client-side Hydrated Bundled
Environment variables Yes No
Reactive Yes Yes
Hot module replacement No Yes
Non-primitive JS types No Yes

Use runtimeConfig for secrets and values that change per environment. Use app.config for public tokens, theme settings, and non-sensitive config.

External Tool Configuration

Nuxt uses nuxt.config.ts as single source of truth. Configure external tools within it:

export default defineNuxtConfig({
  // Nitro configuration
  nitro: {
    // nitro options
  },
  // Vite configuration
  vite: {
    // vite options
    vue: {
      // @vitejs/plugin-vue options
    },
  },
  // PostCSS configuration
  postcss: {
    // postcss options
  },
})

Environment-specific Vite Config

Top-level vite options are shared. Use $client and $server to target a single Vite build:

export default defineNuxtConfig({
  vite: {
    $client: {
      build: { rollupOptions: { output: { manualChunks: { analytics: ['analytics-package'] } } } },
    },
    $server: {
      build: { sourcemap: 'inline' },
    },
  },
})

Vue Configuration

Enable Vue experimental features:

export default defineNuxtConfig({
  vue: {
    propsDestructure: true,
  },
})

Nuxt 5 Default Changes

Many former experimental flags are now on by default. Each can be reverted via the named option:

Behavior Now default Restore Nuxt 4 with
Case-sensitive page routing router.options.sensitive: true router.options.sensitive: false
Typed pages (useRoute/navigateTo/<NuxtLink> type-checked) on experimental.typedPages: false
Page component name = route name on experimental.normalizePageNames: false
All serializable definePageMeta written to route record on experimental.extractSerializablePageMeta: false
Payload inlined in HTML, _payload.json only for SPA nav experimental.payloadExtraction: 'client' payloadExtraction: true
clearNuxtState resets to useState init value on experimental.defaults.useState.resetOnClear: false
await navigateTo() early-returns from setup() on experimental.navigateToEarlyReturn: false
callHook may return void (not always a Promise) on experimental.asyncCallHook: true
Client-only SSR placeholder is a comment node, not <div> on experimental.clientNodePlaceholder: false
Reuse builder's file watcher experimental.watcher: 'builder' watcher: 'chokidar'
Server auto-imports (Nitro helpers) off experimental.nitroAutoImports: true
error.data parsed (never stringified) forced on — (parseErrorData no longer configurable)
Vue Options API compiled out of client bundle on vue: { optionsApi: true }
noUncheckedSideEffectImports in generated tsconfig on typescript.tsConfig.compilerOptions.noUncheckedSideEffectImports: false

Removed options (behavior now unconditional): experimental.viteEnvironmentApi, experimental.routeTypedFetch, experimental.renderJsonPayloads, experimental.externalVue. Delete them from config.

unhead.legacy is ignored (setting it warns); Capo title sorting is always on.

Other Experimental Flags

Notable opt-in flags under experimental (see source for the full list):

export default defineNuxtConfig({
  experimental: {
    // Stream the HTML shell first, then render body progressively (better TTFB)
    ssrStreaming: true,
    // Reject fetches to paths no server route answers (true | 'isomorphic')
    strictRouteTypes: true,
    // Respond 404 for unmatched paths without loading the Vue app/plugins/middleware
    early404: true,
    // Prerender error.vue into 404.html at build time
    prerenderErrorPages: true,
    // Default options for core composables/components
    defaults: {
      nuxtLink: { prefetch: true, prefetchOn: { visibility: true } },
      useAsyncData: { deep: true },
    },
  },
})
<!-- Source references: - https://nuxt.com/docs/getting-started/configuration - https://nuxt.com/docs/getting-started/upgrade - https://nuxt.com/docs/guide/going-further/runtime-config - https://nuxt.com/docs/api/nuxt-config - https://nuxt.com/docs/guide/going-further/experimental-features -->

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.