Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Nuxt Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-nuxt-knowledge-patch)
---
name: nuxt-knowledge-patch
description: Nuxt
version: "4.7.1"
license: MIT
metadata:
author: Nevaberry
---
# Nuxt compatibility and implementation guidance
Load this skill when upgrading a Nuxt application, authoring modules or layers,
or changing data fetching, routing, rendering, builds, or server deployment.
Use the topic references for API examples and version-specific conditions.
> [!CAUTION]
> The Nitro 3 guidance is prerelease and may change before stable release.
> Affected entries carry an explicit prerelease marker in the server reference.
## Reference index
| Reference | Topics |
| --- | --- |
| [Upgrading](references/upgrading.md) | Upgrade commands, removed APIs, compatibility defaults, dependency migrations |
| [Build and types](references/build-and-types.md) | Builders, TypeScript contexts, development servers, diagnostics, profiling |
| [Data fetching and state](references/data-fetching-and-state.md) | Async-data keys, cancellation, cache lookups, payloads, cookies, state |
| [Routing and navigation](references/routing-and-navigation.md) | Page metadata, route rules, layouts, links, transitions, accessibility |
| [Rendering and components](references/rendering-and-components.md) | Hydration, streaming, islands, head metadata, styles, error boundaries |
| [Modules and layers](references/modules-and-layers.md) | Layer precedence, directories, module dependencies, lifecycle hooks, Nuxt Kit |
| [Nitro and deployment](references/nitro-and-deployment.md) | Request handling, caching, prerendering, Nitro 3, deployment presets |
| [Ecosystem modules](references/ecosystem-modules.md) | Nuxt Scripts, Icon, Content, Image, and UI |
## Breaking changes and deprecations
### Upgrade commands and dependency changes
- Run `npx nuxi@latest upgrade --dedupe` to refresh the lockfile and updated transitive dependencies.
- To stay on Nuxt 3, run `npx nuxt upgrade --dedupe --channel=v3`.
If the installed CLI lacks `--channel`, run the same upgrade through `npx nuxi@latest`.
- The optional Nuxt 4 migration command is `npx codemod@latest nuxt/4/migration-recipe`;
review the changes for manual work. Nuxt 3.20 migration instructions pin the recipe to `codemod@0.18.7`.
- Nuxt 4 removes Nuxt 2 compatibility from `@nuxt/kit`.
- For dependencies between Nuxt modules, replace deprecated `installModule()` calls with `moduleDependencies`.
- Nuxt uses Vue Router 5; a direct `unplugin-vue-router` dependency can be removed when upgrading.
Typed routes remain experimental.
### Configuration and API migrations
- Remove `experimental.treeshakeClientOnly`, `experimental.configSchema`,
`experimental.polyfillVueUseHead`, and `experimental.respectNoSSRHeader`.
Use an application plugin for VueUse head compatibility and server middleware for the no-SSR header if needed.
- In app code, use `createError({ status: 404, statusText: 'Not Found' })`.
The older `statusCode` and `statusMessage` names are deprecated.
- Import `mergeModels` from `vue` if calling it directly; Nuxt removed its auto-import.
- Combine page metadata in one `definePageMeta` call; multiple calls in a file raise an error.
- Put custom runtime config outside the reserved `runtimeConfig.app` namespace.
- `vite:extend`, `vite:extendConfig`, and `vite:configResolved` are deprecated as part of the Vite Environment API transition.
### Compatibility and builder choices
- Nuxt 4 detects the existing Nuxt 3 directory layout automatically.
In the `app/` layout, place `app.config.ts` and `error.vue` alongside `app.vue`;
keep `nuxt.config.ts`, `content/`, and `public/` at the project root.
- `future.compatibilityVersion: 4` on Nuxt 3 opts into Nuxt 4 defaults, including shallow async-data payload reactivity.
- For testing, `future.compatibilityVersion: 5` enables the Vite Environment API and future breaking changes,
including Nitro v3 once its integration ships.
- From Nuxt 4.5.1, compatibility version 5 and later defaults `vue.optionsApi` to `false`.
Explicitly enable it if the app or a dependency uses the Options API.
- Nuxt 4.5 uses Vite 8 with Rolldown; check custom Vite plugins and config for compatibility.
The Rspack builder uses Rspack 2 and an Rsbuild middleware dev server, which can affect custom configuration.
- Unhead 3 narrows `useHead` inputs and removes promise input; resolve asynchronous values first.
Nuxt 4.4.8 uses Unhead v2, so match direct `@unhead/vue` dependencies to that major on 4.4.8.
See [upgrading](references/upgrading.md) and [build and types](references/build-and-types.md).
## Security, errors, and request behavior
- After taking the security fixes shipped in 4.5.1 with `npx nuxt upgrade --dedupe`,
purge CDN or edge caches for routes using `cache`, `swr`, or `isr`: earlier `_payload.json` responses may remain cached.
- The security release accompanying 4.5.1 and 3.21.10 also fixes `@nuxt/devtools` in 3.3.1;
refresh the lockfile and check its resolved version. Nuxt 4.6.3 adds Vite dev-server and Nitro request-path security fixes.
- Nuxt 4.6.4 exposes an SSR error's message and data in the production error page and payload
only for errors from `createError()`. Use it for details intended for the client.
- In 4.6.4, add custom or tunnel hostnames to `devServer.allowedHosts` for webpack and Rspack dev servers.
- With Nitropack 2.13.6 in Nuxt 4.6.4, `cache`, `swr`, and `isr` rules cache only `GET` and `HEAD`.
Responses with `Set-Cookie`, `Cache-Control: private`, or `no-store` are excluded from storage.
- In Nuxt 4.6.4, Nitro trusts `X-Forwarded-Proto` only when explicitly opted in.
Set up that opt-in if a trusted-proxy deployment relies on the header for the original scheme.
- During SSR, `useRequestFetch()` forwards request headers even to an absolute destination URL.
See [Nitro and deployment](references/nitro-and-deployment.md) and [rendering](references/rendering-and-components.md).
## Data fetching and state
### Keys, cache lookups, and reusable defaults
- Calls to `useAsyncData` or `useFetch` with the same key share state refs.
When consumers watch the same dependency, a change triggers a single fetch and updates them all.
- `useAsyncData` accepts a ref, computed ref, or getter as its key.
Changing the key fetches the new data; the previous result can remain available while fetching.
- From 4.4.6, reactive inputs can change a `useFetch` key even with `watch: false`.
Pass a fixed string as `key` when the cache entry should keep the same key.
- Return `undefined` from `getCachedData` to run the handler; `null` counts as cached data.
- Use `createUseFetch` or `createUseAsyncData` for reusable defaults with automatic SSR key injection.
Call-site options override object defaults; a factory function controls option merging.
- Set `experimental.purgeCachedData` to `false` if relying on cache survival after consumers unmount.
### Execution and cancellation
`enabled` is reactive on `useFetch` and `useAsyncData` and gates initial, watched,
and manual executions. Setting it to `false` cancels an in-flight execution and preserves existing data.
Forward the handler's `signal` to `$fetch` so `clear()` or a refresh with
`dedupe: 'cancel'` aborts the request. Pass an `AbortController` signal to `refresh()` or `execute()` to cancel a run yourself.
```ts
const { refresh } = await useAsyncData('users', (_nuxtApp, { signal }) =>
$fetch('/api/users', { signal }),
)
const controller = new AbortController()
refresh({ signal: controller.signal })
// Call when the refresh should be cancelled.
controller.abort()
```
`clear()` resets `data` to `undefined`, `error` to `null`, `pending` to `false`,
and `status` to `'idle'`, marking pending requests as cancelled.
### Payloads, cookies, and state reset
- Payload extraction applies only to SSR routes. For ISR and SWR routes,
`experimental.payloadExtraction: 'client'` inlines the full initial payload while keeping `_payload.json` for navigation.
This mode becomes the default with compatibility version 5.
- Enabling preview mode reruns `useAsyncData` and `useFetch` and bypasses cached payload data.
- With `refresh: true`, assigning a cookie's current value back restarts its `maxAge` countdown.
In 4.6.3, Cookie Store API updates preserve expiration with this option.
- In 4.7.1, calls to `useCookie()` for the same cookie share a ref outside components.
- `clearNuxtState` restores the initial value for state created with a `useState` initializer.
See [data fetching and state](references/data-fetching-and-state.md).
## Routing, layouts, and links
- Use `appMiddleware` in page route rules for named middleware; a name mapped to `false` disables it.
- Use `appLayout` in route rules to select a layout. In `definePageMeta`, a layout object with
`name` and `props` types the props against the layout's `defineProps` declaration.
- `useLayout()` returns a readonly computed ref to the resolved layout and follows navigation and layout selection.
- With `experimental.inlineRouteRules`, modules can read extracted `defineRouteRules()` values from `page.rules`
or assign rules to a page record in `pages:extend`.
- Nuxt 4.5.1 warns and drops an inline rule that cannot map the page path to an equivalent route-rule pattern;
configure the intended URL pattern in top-level `routeRules` in that case.
- In 4.6.3, `navigateTo` returns a redirect target only in route middleware.
Return `navigateTo(...)` from middleware and await it in ordinary app code.
- From 4.6.3, `/docs/*` in a `noScripts` rule matches one segment; use `/docs/**` for nested paths.
- From 4.6.4, encoded slashes can separate segments in route-rule matching: `/api/**` also covers `/api%2Fadmin`.
- Configure app-wide link prefetch triggers with `experimental.defaults.nuxtLink.prefetchOn`;
use `prefetch-on="interaction"` on a link for hover or focus.
- A custom `NuxtLink` slot exposes `prefetch()`, `prefetched`, and `shouldPrefetch(trigger)` for custom markup.
- Keep `<NuxtRouteAnnouncer />` in a custom root template for navigation announcements.
Use `<NuxtAnnouncer />` and `useAnnouncer()` for in-page updates while focus stays where it is.
See [routing and navigation](references/routing-and-navigation.md).
## Hydration, islands, and head metadata
- Lazy components support `hydrate-on-idle`, `hydrate-on-interaction`, `hydrate-on-media-query`, and `hydrate-after`.
Listen for `@hydrated` to run code when delayed hydration finishes.
- Use `defineLazyHydrationComponent` with a strategy and dynamic import for an explicitly imported component.
It works with `imports.autoImport: false` and with `components: false`.
- Use `onPrehydrate` for browser code before Vue hydrates server-rendered HTML.
- Experimental SSR streaming flushes the shell first and commits HTTP status and headers before rendering finishes.
Set `streaming: false` for routes setting status, headers, or cookies during rendering.
Expect buffered responses for crawlers and routes with `redirect`, `cache`, `isr`, `swr`, `noScripts`, or `ssr: false`.
- Static hosting of server components requires crawling pages using them, rendering them during generation,
and keeping their props fixed at runtime. Nuxt runs app plugins during island rendering.
- Pass island props as an object. Nuxt 4.5.1 and 3.21.10 reject top-level `as` props
and reject `template` when the Vue runtime compiler is enabled.
- Use auto-imported head composables or `#app/composables/head`;
direct imports from `@unhead/vue` can lose Nuxt's async context.
- From 4.4.5, head updates wait for page transitions to finish.
Nuxt 4.6.2 applies `useHeadSafe` rules to head entries from server islands.
See [rendering and components](references/rendering-and-components.md).
## Modules, layers, and tooling
- Project files override auto-scanned layers, which override `extends` layers.
Later alphabetical auto-scanned layer names win; the first `extends` entry has highest priority.
- Runtime-independent `shared/` code must avoid Vue and Nitro imports; both runtimes can import via `#shared`.
- `getLayerDirectories()` exposes resolved layer directories, including `appPages`, `app`, `server`, and `public`.
- `moduleDependencies` loads dependencies before the declaring module; `optional: true` limits an entry to projects already using it.
Option precedence is `overrides`, project configuration, `defaults`, then the dependency's own defaults.
- Use `onInstall(nuxt)` and `onUpgrade(inlineOptions, nuxt, previousVersion)` for module lifecycle work.
Commit `.nuxtrc`, where Nuxt records module versions.
- Maintain one root `tsconfig.json`; Nuxt generates separate app, server, shared, and build-time TypeScript projects.
- `nuxt build --profile` records timings and memory changes for build phases, modules, and bundler plugins.
Use `--profile=verbose` to print timing breakdowns.
- `nuxt typecheck` detects Golar when installed or when a `golar.config.*` file exists;
select explicitly with `--checker=golar` or `--checker=vue-tsc`.
See [modules and layers](references/modules-and-layers.md) and [build and types](references/build-and-types.md).
## Ecosystem migrations
- Nuxt Image v2 requires Nuxt 3.1 or later. Replace named provider `getImage` exports with
a default export using `defineProvider` from `@nuxt/image/runtime`; replace `joinWith` with `formatter`.
- Image v2 removes `layer0` and `edgio`; switch providers before upgrading.
Restore `xs` (320 px) and `xxl` (2560 px) if image `sizes` rely on those breakpoints.
- In Content v3, replace `ContentSlot` with `Slot`. Development, server hosting, and static generation
work without database setup; for serverless hosting, select a persistent adapter through the Content database configuration.
- Nuxt UI v4 includes former Pro components in `@nuxt/ui`.
Its AI SDK v5 chat integration reads message content from `message.parts`.
- `useScript` exposes a typed proxy safe to call during SSR and queues early client calls until the script loads.
Use `onLoaded` for direct access to the loaded API.
See [ecosystem modules](references/ecosystem-modules.md) for examples and the remaining module guidance.