Upgrade Guide
Upgrading Nuxt
Latest release
To upgrade Nuxt to the latest release, use the nuxt upgrade command.
npx nuxt upgradeyarn nuxt upgradepnpm nuxt upgradebun x nuxt upgradedeno x nuxt upgradeNightly Release Channel
To use the latest Nuxt build and test features before their release, read about the nightly release channel guide.
Migrating to Nuxt 5
Nuxt 5 includes significant improvements and changes. This guide covers what changed and how to migrate an existing Nuxt 4 application.
First, upgrade Nuxt using the instructions above.
h3, nitropack or #imports, or call useRuntimeConfig(event)), set nitroLegacy: true first to get the app running, then migrate one part at a time. See Nitro v2 Compatibility.Most Nuxt 5 behavior is the new default. Where a change can still be configured, the section describing it names the option that restores the Nuxt 4 behavior; where it cannot, the section says so.
The changes are:
- Node.js versions: Nuxt 5 requires Node.js
^22.22.0,^24.15.0or>=26.0.0 - Nitro v3: The server engine is rewritten on h3 v2 and srvx, with a compatibility layer for server code you have not migrated yet
- Server imports: Server utilities come from
nuxt/server, including session helpers - Vite Environment API: Vite plugins are registered and configured per environment
- Vite 8: The bundler is Rolldown rather than esbuild and Rollup
- Nitro as a Vite environment: With
@nuxt/vite-builder, server and client are built by one Vite build - Rsbuild builder:
@nuxt/rspack-builderis deprecated in favour of@nuxt/rsbuild-builder - Typed
$fetch:$fetchanduseFetchare typed from generated route types rather than nitro'sInternalApi - No client
globalThis.$fetch: In the browser,$fetchis an import rather than a global jitiis no longer bundled:nuxt.config,modules/and layer configs are loaded by the runtimeprocess.*type augmentation removed: TypeScript no longer exposes deprecatedprocess.*flags onNodeJS.Process- Case-sensitive routing: Page routes match URL casing exactly, consistent with Nitro
- Normalized page names: Page component names match their route names for consistent
<KeepAlive>behavior - Serializable page meta: Statically analysable
definePageMetavalues are written into the generated route record - Client-side payload extraction:
experimental.payloadExtractionis'client', inlining the payload in the HTML of a prerendered page clearNuxtStateresets to defaults:clearNuxtStateresets state to its initial value instead of setting it toundefined- Early return from
navigateTo: A successful top-levelawait navigateTo()stops the rest of yoursetup()running noopenerfornavigateTo: Windows opened withnavigateTo(url, { open })getnoopenerby default, so they cannot accesswindow.opener- Server-side error boundaries:
<NuxtErrorBoundary>catches errors thrown while server-rendering its default slot instead of letting them reach the error page - Non-async
callHook:callHookmay returnvoidinstead of always returning aPromise - Comment node placeholders: Client-only components use comment nodes instead of
<div>as SSR placeholders, fixing a scoped styles hydration issue - Server auto-imports off: Server code imports Nitro's helpers explicitly rather than relying on the auto-import layer
- Typed runtime config environment variables: Environment variables are converted to the type of the runtime config value they replace, and runtime config can be declared with a schema
- Top-level
server/utils/only: Files in subdirectories ofserver/utils/are no longer auto-imported - Parsed
error.data:experimental.parseErrorDatais forced on, soerror.datareaches the error page unstringified - Error response format: Page errors return the error page and server route errors return JSON, regardless of the request headers
- Builder file watcher: Nuxt reuses the builder's own watcher in development instead of starting a second one
- Server-only head composables:
useServerHead,useServerHeadSafeanduseServerSeoMetaare no longer auto-imported, andunhead.legacyis ignored - Vue Options API disabled: The Options API is compiled out of the client bundle to reduce its size
- Typed pages:
experimental.typedPagesis enabled by default for type-checked routing - Node-resolution config types: The generated
nodetsconfig describes how the runtime loadsnuxt.configand modules - Stricter side-effect imports: The generated
tsconfig.jsonenablesnoUncheckedSideEffectImportsto match the TypeScript 7 default - TypeScript
baseUrlignored: Generated TypeScript configurations no longer usecompilerOptions.baseUrlto resolve Nuxt aliases - PostCSS plugins:
autoprefixerandcssnanoare no longer installed or configured by default - Optional dependencies:
@vitejs/plugin-vue-jsxandgigetare installed on demand - Peer dependencies:
vueandvue-routercome from your project, withvue-routeronly needed when pages are enabled - Proxy environment variables: Build-time requests use Node's built-in proxy support instead of
undici, which on Node.js 22 needsNODE_USE_ENV_PROXY=1 - Removed options: Several experimental options are gone, because the behavior they controlled is now unconditional
Breaking or significant changes are documented below along with migration steps and the configuration available for each.
Node.js Version Requirements
🚦 Impact Level: Minimal
What Changed
Nuxt 5 supports Node.js ^22.22.0, ^24.15.0 and >=26.0.0. On Node.js 24, the minimum is now 24.15.0, matching current Nuxt 4 releases.
Migration Steps
If you run Node.js 24.11 to 24.14, upgrade to the latest Node.js 24 release.
process.* Type Augmentation Removed
🚦 Impact Level: Minimal
What Changed
Nuxt no longer augments NodeJS.Process with browser, client, dev, server, and test. Build-time defines for those flags remain for compatibility, but TypeScript will not treat them as known properties.
Prefer import.meta.*. Those flags are replaced at build time and stay tree-shakeable.
Migration Steps
Replace legacy checks in your app code, modules, and libraries:
// Before
// eslint-disable-next-line nuxt/prefer-import-meta
if (process.server) {
/* ... */
}
// After
if (import.meta.server) {
/* ... */
}The nuxt/prefer-import-meta ESLint rule flags remaining process.* usage.
Case-Sensitive Routing
🚦 Impact Level: Minimal
What Changed
router.options.sensitive now defaults to true, so page routes match URLs case-sensitively, consistent with Nitro. For example, /About no longer matches pages/about.vue.
sensitive is now read only from nuxt.config, because the server matches route rules with the same setting. The build fails if app/router.options.ts sets it.
Migration Steps
Update links to use the same casing as their page routes. To keep case-insensitive matching, set sensitive in nuxt.config (and remove it from app/router.options.ts if it is there):
export default defineNuxtConfig({
router: {
options: {
sensitive: false,
},
},
})If you opt out, regex constraints in your route rules must be written for lower-case letters.
Normalized Page Component Names
🚦 Impact Level: Minimal
What Changed
experimental.normalizePageNames is now enabled by default, so page components are named after their route rather than after their filename. pages/foo/index.vue and pages/bar/index.vue are named foo and bar instead of both being named index.
Migration Steps
If you filter <KeepAlive> by component name, update include/exclude to the route names. To keep the filename-based names:
export default defineNuxtConfig({
experimental: {
normalizePageNames: false,
},
})Serializable Page Meta Extracted at Build Time
🚦 Impact Level: Minimal
What Changed
experimental.extractSerializablePageMeta is now enabled by default. Every JSON-serializable definePageMeta() property is written into the generated route record, rather than only a fixed list of keys (plus experimental.extraPageMetaExtractionKeys) with the rest resolved at runtime from a per-page meta module.
Properties whose values cannot be serialized, such as functions, variable references and spreads, are still resolved at runtime.
Migration Steps
If you read page meta from the route record at build time (in a pages:extend hook, for example), expect to see the extracted values there. To keep the previous behavior:
export default defineNuxtConfig({
experimental: {
extractSerializablePageMeta: false,
},
})Payload Extraction Defaults to 'client'
🚦 Impact Level: Minimal
What Changed
experimental.payloadExtraction now defaults to 'client' rather than true. The payload of a prerendered or cached page is inlined in the HTML for the initial render, and the _payload.json file is only fetched for client-side navigation. It is still forced to false when ssr is disabled.
Migration Steps
No change is needed for most applications. If you fetch _payload.json for the initial render yourself, or measure HTML size in a test, set the option explicitly:
export default defineNuxtConfig({
experimental: {
payloadExtraction: true,
},
})Respect Defaults When Clearing useState
🚦 Impact Level: Minimal
What Changed
experimental.defaults.useState.resetOnClear is now enabled by default, so clearNuxtState resets state to the value produced by the init function of useState instead of setting it to undefined.
Migration Steps
If your code checks for undefined after clearing state, check for the initial value instead. To keep the previous behavior:
export default defineNuxtConfig({
experimental: {
defaults: {
useState: {
resetOnClear: false,
},
},
},
})Early Return From navigateTo
🚦 Impact Level: Minimal
What Changed
experimental.navigateToEarlyReturn is now enabled by default. A top-level await navigateTo() in <script setup> is compiled into an early return from setup() when the navigation succeeds, so the rest of the setup code does not run and the component renders a placeholder comment while the navigation proceeds.
Migration Steps
If you relied on code after a successful await navigateTo() running, move it before the navigation. To keep the previous behavior:
export default defineNuxtConfig({
experimental: {
navigateToEarlyReturn: false,
},
})noopener for Windows Opened by navigateTo
🚦 Impact Level: Minimal
What Changed
experimental.defaults.navigateTo.noopener is now enabled by default, so navigateTo with the open option passes noopener to window.open unless open.windowFeatures.noopener is set. The opened page can no longer access your application through window.opener, and a named target (other than _self, _parent and _top) opens a new window each time rather than reusing an existing one with that name.
Migration Steps
If an opened page relies on window.opener (for example, an OAuth popup that calls window.opener.postMessage()), or you reuse a named window, set noopener: false for that call:
await navigateTo('https://auth.example.com/authorize', {
external: true,
open: { windowFeatures: { popup: true, noopener: false } },
})To keep the previous behavior everywhere:
export default defineNuxtConfig({
experimental: {
defaults: {
navigateTo: {
noopener: false,
},
},
},
})<NuxtErrorBoundary> Catches Server-Side Errors
🚦 Impact Level: Medium
What Changed
experimental.ssrErrorBoundary is now enabled by default. When content inside a <NuxtErrorBoundary> throws during server-side rendering, the boundary renders its #error slot in the HTML response with a 200 status, and the client hydrates into the same state. Previously the error escaped to the full-screen error page, with the error's status code.
This includes errors created with createError({ status: 404 }) in a page's setup: if <NuxtPage> or a layout's <slot /> is wrapped in a boundary, such a page now responds with 200 and the boundary's #error slot.
<NuxtClientFallback> and experimental.clientFallback are deprecated in favour of <NuxtErrorBoundary retry-on-client>.
Migration Steps
If a page relies on throwing an error to respond with the error page and its status code, move the boundary so that it does not wrap the page, or call showError instead of throwing. To keep the previous behaviour:
export default defineNuxtConfig({
experimental: {
ssrErrorBoundary: false,
},
})Builder File Watcher in Development
🚦 Impact Level: Minimal
What Changed
experimental.watcher now defaults to 'builder', so Nuxt reuses the active builder's file watcher (Vite's server.watcher, for example) instead of starting a second one. If the builder provides no watcher, Nuxt falls back to its previous selection.
Migration Steps
If you depend on watching files the builder ignores, name a watcher explicitly:
export default defineNuxtConfig({
experimental: {
watcher: 'chokidar',
},
})jiti Is No Longer Bundled
🚦 Impact Level: Medium
What Changed
Nuxt no longer depends on jiti. Files loaded outside the bundler (nuxt.config.ts, files in modules/, and layer configs) are now imported by the runtime itself.
You can still write your config in TypeScript. Nuxt 5 requires Node 22.22, 24.15 or later, where type stripping is on by default, so nuxt.config.ts and TypeScript modules load natively. Two things the runtime does not do, which jiti used to paper over, are guess file extensions and compile TypeScript syntax that emits code.
Both would otherwise only surface when Nuxt loads the file, so the generated node tsconfig now describes the environment the way the runtime sees it (module and moduleResolution set to nodenext, plus erasableSyntaxOnly) and TypeScript reports both up front.
That covers nuxt.config, modules/ and layer configs only. Your app and shared/ code go through Vite and resolve the way they always have. If you need the previous behavior, override it:
export default defineNuxtConfig({
typescript: {
nodeTsConfig: {
compilerOptions: {
module: 'preserve',
moduleResolution: 'bundler',
erasableSyntaxOnly: false,
},
},
},
})Reasons for Change
jiti was pulled into every Nuxt install to load a handful of files, most of which the runtime can now load unaided. Removing it makes a default install smaller.
Migration Steps
1. Add file extensions to relative imports.
Relative imports in nuxt.config.ts, modules/, and layer configs need an explicit extension:
- import { myPlugin } from './build/my-plugin'
+ import { myPlugin } from './build/my-plugin.ts'TypeScript reports a missing extension as TS2835. Note that its quick fix suggests ./build/my-plugin.js; write the extension the file actually has (.ts), which Node resolves directly.
Bare package imports (import { defu } from 'defu') are unaffected.
JSON imports need an import attribute:
- import pkg from '../package.json'
+ import pkg from '../package.json' with { type: 'json' }Nuxt aliases such as ~/ and #shared are not resolved outside the bundler, so use a relative import instead:
- import { CONSTANTS } from '#shared/utils/constants'
+ import { CONSTANTS } from '../shared/utils/constants.ts'2. Use erasable TypeScript syntax.
Type annotations are erased, but syntax that emits runtime code cannot be. In config and module files, replace:
enum Foo {}with aconstobjectnamespace/moduleblocks with plain exports- constructor parameter properties (
constructor(private x: string) {}) with an explicit assignment - experimental decorators
TypeScript reports all of these for you as TS1294.
3. If you publish a layer or module, ship compiled JavaScript.
This one is specific to packages. The runtime refuses to strip types from any file inside node_modules, whatever the configuration, so a published entrypoint written in TypeScript cannot be loaded natively however new the Node version is. Build to JavaScript before publishing, and if your package ships a nuxt.config, emit it as nuxt.config.mjs. Otherwise every consuming project has to install jiti.
This does not apply to layers inside your own project: layers/*/nuxt.config.ts loads natively.
4. Install jiti if you still need it.
jiti is now an optional peer dependency. Install it and Nuxt will pick it up automatically as a fallback whenever the runtime cannot load a file on its own:
npm i -D jitiyarn add -D jitipnpm add -D jitibun add -D jitinuxt.schema files are imported by the runtime in the same way, and Nuxt reads their JSDoc annotations as they are imported. So they follow the same rules as config files: a nuxt.schema.ts inside node_modules, such as one shipped by a published layer, is loaded through jiti. On a runtime without module.registerHooks(), such as Bun, every nuxt.schema file is loaded through jiti.
One smaller change comes with this: PostCSS plugins named in postcss.plugins are now resolved by the runtime, so a plugin name that only resolves through a Nuxt alias entry no longer loads. Use the package name, or a path.
Migration to Vite Environment API
🚦 Impact Level: Medium
What Changed
Nuxt 5 migrates to Vite 6's new Environment API, which formalizes the concept of environments and provides better control over configuration per environment.
Previously, Nuxt used separate client and server Vite configurations. Now, Nuxt uses a shared Vite configuration with environment-specific plugins that use the applyToEnvironment() method to target specific environments.
experimental.viteEnvironmentApi option has been removed.Key changes:
- Deprecated environment-specific
extendViteConfig(): Theserverandclientoptions inextendViteConfig()are deprecated and will show warnings when used. - Changed plugin registration: Vite plugins registered with
addVitePlugin()and only targeting one environment (by passingserver: falseorclient: false) will not have theirconfigorconfigResolvedhooks called. - Shared configuration: The
vite:extendConfigandvite:configResolvedhooks now work with a shared configuration rather than separate client/server configs.
Reasons for Change
The Vite Environment API provides:
- Better consistency between development and production builds
- More granular control over environment-specific configuration
- Improved performance and plugin architecture
- Support for custom environments beyond just client and server
Migration Steps
1. Migrate to use Vite plugins
We would recommend you use a Vite plugin instead of extendViteConfig, vite:configResolved and vite:extendConfig.
// Before
extendViteConfig((config) => {
config.optimizeDeps.include.push('my-package')
}, { server: false })
nuxt.hook('vite:extendConfig' /* or vite:configResolved */, (config, { isClient }) => {
if (isClient) {
config.optimizeDeps.include.push('my-package')
}
})
// After
addVitePlugin(() => ({
name: 'my-plugin',
config (config) {
// you can set global vite configuration here
},
configResolved (config) {
// you can access the fully resolved vite configuration here
},
configEnvironment (name, config) {
// you can set environment-specific vite configuration here
if (name === 'client') {
config.optimizeDeps ||= {}
config.optimizeDeps.include ||= []
config.optimizeDeps.include.push('my-package')
}
},
applyToEnvironment (environment) {
return environment.name === 'client'
},
}))2. Migrate Vite plugins to use environments
Instead of using addVitePlugin with server: false or client: false, you can instead use the new applyToEnvironment hook within your plugin.
// Before
addVitePlugin(() => ({
name: 'my-plugin',
config (config) {
config.optimizeDeps.include.push('my-package')
},
}), { client: false })
// After
addVitePlugin(() => ({
name: 'my-plugin',
config (config) {
// you can set global vite configuration here
},
configResolved (config) {
// you can access the fully resolved vite configuration here
},
configEnvironment (name, config) {
// you can set environment-specific vite configuration here
if (name === 'client') {
config.optimizeDeps ||= {}
config.optimizeDeps.include ||= []
config.optimizeDeps.include.push('my-package')
}
},
applyToEnvironment (environment) {
return environment.name === 'client'
},
}))Migration to Vite 8
🚦 Impact Level: Medium
What Changed
Nuxt 5 upgrades from Vite 7 to Vite 8, which replaces esbuild and Rollup with Rolldown as the underlying bundler. This brings significantly faster builds but includes several breaking changes.
"vite": "^8.3.0" resolution override in your package.json.Most of the migration is handled by Nuxt internally, but there are some user-facing changes to be aware of:
vite.esbuildandvite.optimizeDeps.esbuildOptionsare deprecated in favor ofvite.oxcandvite.optimizeDeps.rolldownOptions. Vite 8 converts these automatically for now, but they will be removed in the future.build.rollupOptionsis deprecated in favor ofbuild.rolldownOptions.- CommonJS interop behavior has changed. If you import CJS modules, review the Vite 8 migration guide for details.
Nitro Builds as a Vite Environment
🚦 Impact Level: Medium
What Changed
With @nuxt/vite-builder, experimental.nitroViteEnvironment now defaults to true, so Nitro is built as a Vite environment through the nitro/vite plugin rather than through Nitro's own Rolldown pipeline. Server and client are built by one Vite build, and server code goes through the Vite plugins and resolution your app code already uses.
The option has no effect with other app builders, which keep Nitro's own pipeline. Setting it to true there logs a warning.
Migration Steps
Plugins in nitro.rollupConfig.plugins still run in the nitro environment, but after Vite's own resolution and core transforms. A plugin that has to resolve or transform a module before Vite does needs to be a Vite plugin with enforce: 'pre'.
addVitePlugin() only registers plugins for the app's environments, so add a plugin for the server build to vite.plugins directly, scoped with applyToEnvironment:
import { defineNuxtModule } from '@nuxt/kit'
export default defineNuxtModule({
setup (_options, nuxt) {
nuxt.options.vite.plugins ||= []
nuxt.options.vite.plugins.push({
name: 'my-module:server',
enforce: 'pre',
applyToEnvironment: environment => environment.name === 'nitro',
resolveId (id) {
// ...
},
})
},
})To keep Nitro's own build pass:
export default defineNuxtConfig({
experimental: {
nitroViteEnvironment: false,
},
})Rspack Builder Is Replaced by the Rsbuild Builder
🚦 Impact Level: Medium (only if you use builder: 'rspack')
What Changed
Nuxt has a new builder, @nuxt/rsbuild-builder, enabled with builder: 'rsbuild'. It builds your app with Rsbuild, which runs on Rspack, and is configured with the new rsbuild option.
@nuxt/rspack-builder is deprecated and logs a warning. It still works in Nuxt 5 and will be removed in a future major version.
Reasons for Change
@nuxt/rspack-builder generates its Rspack configuration from the webpack builder's presets, with loaders for CSS, PostCSS, esbuild and assets. @nuxt/rsbuild-builder uses Rsbuild's own handling of these instead (SWC for scripts, Lightning CSS for styles), with the Rsbuild plugin ecosystem.
Migration Steps
Replace @nuxt/rspack-builder with @nuxt/rsbuild-builder:
npm uninstall @nuxt/rspack-builder
npm install -D @nuxt/rsbuild-builderyarn remove @nuxt/rspack-builder
yarn add -D @nuxt/rsbuild-builderpnpm remove @nuxt/rspack-builder
pnpm add -D @nuxt/rsbuild-builderbun remove @nuxt/rspack-builder
bun add -D @nuxt/rsbuild-builderThen update the builder in your nuxt.config:
export default defineNuxtConfig({
- builder: 'rspack',
+ builder: 'rsbuild',
})The Rsbuild builder does not read the webpack options, so move any you set to the rsbuild option. For example, webpack.loaders.vue becomes rsbuild.vue.vueLoaderOptions, and options for one build go under rsbuild.environments.client or rsbuild.environments.ssr. PostCSS plugins are still configured with postcss.plugins, and build.analyze writes an Rsdoctor report.
Install the Rsbuild plugin for each language you use instead of its webpack loader. Nuxt registers these plugins when they are installed, and warns when a file needs one that is missing.
| Language | webpack loader | Rsbuild plugin |
|---|---|---|
| Sass/SCSS | sass-loader | @rsbuild/plugin-sass |
| Less | less-loader | @rsbuild/plugin-less |
| Stylus | stylus-loader | @rsbuild/plugin-stylus |
| Pug | pug-plain-loader | @rsbuild/plugin-pug |
Type checking with typescript.typeCheck uses @rsbuild/plugin-type-check, which Nuxt offers to install when it is missing.
For Module Authors
addRspackPlugin(),extendRspackConfig()andaddBuildPlugin()with anrspackplugin keep working, and therspack:configandrspack:configResolvedhooks are still called. The Rspack configurations are generated by Rsbuild, so theirmodule.rulesdiffer from the ones of@nuxt/rspack-builder. To change how files are processed, useextendRsbuildConfig()oraddRsbuildPlugin().The server build is named
ssrrather thanserver. Code that looks up the server configuration inrspack:configneeds to check for both:nuxt.hook('rspack:config', (configs) => { - const server = configs.find(config => config.name === 'server') + const server = configs.find(config => config.name === 'server' || config.name === 'ssr') })- The
rspack:compileandrspack:compiledhooks are not called. Usersbuild:compileandrsbuild:compiled, which receive the environmentname, its Rspackcompilerand, once compiled, itsstats.
Server Imports Move to nuxt/server
🚦 Impact Level: Medium
What Changed
Nuxt 5 ships nuxt/server, an import surface for the server utilities server code reaches for most: defineHandler, createError, getQuery, readBody, the cookie and header helpers, sendRedirect, getRouteRules and useRuntimeConfig.
In Nuxt 4, server code imports these from h3 or gets them as auto-imports, which ties it to h3 v1 and nitropack. Importing from nuxt/server instead works with whichever server.builder is configured, so one file can serve Nuxt 4.6 (running either nitropack v2 or Nitro v3) and Nuxt 5.
- import { defineEventHandler, getQuery } from 'h3'
+ import { defineHandler, getQuery } from 'nuxt/server'
- export default defineEventHandler((event) => {
+ export default defineHandler((event) => {
return getQuery(event)
})nuxt/server also exports defineEventHandler as an alias of defineHandler, so renaming your handlers is optional.
Errors take the same shape as the ones the Vue part of your app constructs:
- import { createError } from 'h3'
+ import { createError } from 'nuxt/server'
export default defineHandler(() => {
- throw createError({ statusCode: 400, statusMessage: 'Bad request' })
+ throw createError({ status: 400, statusText: 'Bad request' })
})Server auto-imports are off by default in Nuxt 5. A project that enables them with experimental.nitroAutoImports gets nuxt/server through them, so it needs no import changes.
Migration Steps
- Replace
h3imports withnuxt/server, for the utilities in the surface. - Import anything else from
nitro/h3.nuxt/serveris not a re-export of h3, so helpers such asproxyRequestare not part of it. - Update calls affected by the differences from h3 v1, whether the helpers are imported or auto-imported.
Differences From h3 v1
| h3 v1 | nuxt/server |
|---|---|
sendRedirect(event, location) sends the response. | Returns the response body: return sendRedirect(event, '/login'). |
getRouterParam(event, name) and getRouterParams(event) return decoded values. | They return values as they appear in the URL. Pass { decode: true } to decode them. |
handleCors(event, options) returns true when it answered a preflight request. | Returns the preflight Response, or false: const preflight = handleCors(event, options); if (preflight) return preflight. |
handleCors accepts a single origin string at runtime. | origin is '*', 'null', an array of origins or patterns, or a function: wrap a single origin in an array. maxAge is a string of seconds, such as '86400', or false. Import the CorsOptions type from nuxt/server. |
readValidatedBody and getValidatedQuery take a validation function. | They take a Standard Schema or a function. |
createError({ statusCode, statusMessage }) | createError({ status, statusText }) |
isError(error) | isNuxtError(error) |
h3's useSession, getSession, updateSession and clearSession seal an h3 cookie with the password you pass. | They seal a nuxt-session cookie, by default with a secret derived from appSecret. A session one issues does not unseal with the other, so users get a new session once. See Sessions Come From nuxt/server. |
useRuntimeConfig(event) | useRuntimeConfig(). There is no per-request form. |
Global $fetch | Not part of nuxt/server. Call a route of the app with serverFetch(event, path), which returns a Response. For other URLs, plain fetch does not throw on a non-2xx status and does not parse JSON: check response.ok and call response.json(). |
event.path | getRequestURL(event).pathname, or event.url.pathname. |
event.node | Not available. Use event.req and event.res. |
getResponseHeader, setResponseHeader, appendResponseHeader, removeResponseHeader | event.res.headers.get(), .set(), .append(), .delete() |
getMethod(event), isMethod(event, method), assertMethod(event, method) | Compare event.req.method. |
readMultipartFormData(event) | await event.req.formData() |
readRawBody(event), getRequestWebStream(event) | await event.req.arrayBuffer() (or .text()), event.req.body |
toWebRequest(event) | event.req, which is already a Request |
sanitizeStatusCode | Not provided. |
Sessions Come From nuxt/server
🚦 Impact Level: Medium
What Changed
useSession, getSession, updateSession and clearSession are now part of nuxt/server, and are what the auto-imported names resolve to. They seal the session with iron-webcrypto on web-standard Request and Response, so they run under any server.builder rather than only under Nitro.
A session issued by the h3 helpers does not unseal with these, and the default cookie name is nuxt-session rather than h3. Everyone signed in before the upgrade gets a fresh, empty session once.
A password is no longer required. Without one, the session is sealed with a secret derived from appSecret, which NUXT_APP_SECRET sets:
export default defineEventHandler(async (event) => {
- const session = await useSession<{ user?: string }>(event, {
- password: process.env.NUXT_SESSION_PASSWORD!,
- })
+ const session = await useSession<{ user?: string }>(event)
return { user: session.data.user }
})Passing a password of at least 32 characters still seals with that instead.
To keep h3's implementation, import it explicitly:
+ import { useSession } from 'nitro/h3'
export default defineEventHandler(async (event) => {
const session = await useSession(event, { password: process.env.NUXT_SESSION_PASSWORD! })
return { user: session.data.user }
})Migration Steps
- Plan for existing sessions ending: users are signed out once, on the deploy that upgrades them.
- Where you relied on h3-specific options (
sessionHeader,crypto,seal), either importuseSessionfromnitro/h3or move to thenuxt/serverequivalents:name,maxAgeandcookie. - Set
NUXT_APP_SECRETin every deployed environment if you droppassword; in development Nuxt generates one. - Set the cookie name to
h3only if you also keep h3's helpers; the two implementations should not share a cookie.
Runtime Config Environment Variables Follow the Type of Their Value
🚦 Impact Level: Moderate
What Changed
An environment variable that overrides a runtime config value is converted to the type of the value in nuxt.config, rather than guessed from its contents with destr. NUXT_PORT=8080 is a number when port defaults to 3000, and NUXT_API_SECRET=4848e0 stays a string when apiSecret defaults to ''.
The server does not start if a variable cannot be converted (for example NUXT_PORT=abc), and reports NUXT_E8014.
Runtime config values can also be declared with a Standard Schema, such as a Zod or ArkType schema, to set their type without a default or to make them required.
Migration Steps
- Remove literal double quotes that were only there to keep a value a string, such as
NUXT_MY_VAR='"4848e0"'. With a string default, the quotes are now part of the value. - Make sure each default has the type you read it as. A value that defaults to
''but is set toNUXT_RETRIES=3is now the string'3'. Give it a numeric default, or a schema:
import { z } from 'zod'
export default defineNuxtConfig({
runtimeConfig: {
retries: 3,
apiSecret: z.string(),
},
})Plain values that default to null or undefined are replaced with an empty string, so they are set as strings too. A schema such as z.number().nullable().default(null) keeps its null default.
Migration to Nitro v3
🚦 Impact Level: Significant
What Changed
Nuxt 5 upgrades to Nitro v3, which is a major rewrite of the server engine. Nitro v3 is built on srvx and h3 v2, adopting Web standard Request/Response APIs throughout. This brings performance improvements and a more consistent API, but includes several breaking changes to server-side code.
The sections below highlight changes that are most relevant to Nuxt application developers and module authors. You don't have to make all of them before you upgrade: see Nitro v2 Compatibility for the layer that keeps older server code running in the meantime.
Package and Import Path Changes
The nitropack package has been renamed to nitro. All import paths have changed:
| Before | After |
|---|---|
nitropack | nitro |
nitropack/types | nitro/types |
nitropack/runtime | nitro |
h3 (for server utilities) | nitro/h3 |
If you have explicit imports in server code, update them:
- import { defineEventHandler, getQuery } from 'h3'
+ import { defineEventHandler, getQuery } from 'nitro/h3'For module authors, type augmentations must target the new module path:
- declare module 'nitropack/types' {
+ declare module 'nitro/types' {
interface NitroRuntimeConfig {
myModule?: { /* ... */ }
}
}Route rules are augmented on a different module again. See Route Rule Types Move to h3/rules.
Server Auto-Imports Are Now Opt-In
Nitro v3 removed its auto-import support, so utilities such as defineEventHandler, getQuery, readBody and useRuntimeConfig are no longer global in server code. Nuxt still provides them, but in Nuxt 5 they are off by default. If server code uses one of them without importing it, the build warns with NUXT_B9007 and lists the imports to add.
Add explicit imports to your server code. Prefer nuxt/server, which is what the auto-imports resolve to:
+ import { defineEventHandler, getQuery } from 'nuxt/server'
+
export default defineEventHandler((event) => {
return getQuery(event)
})Or keep the previous behavior while you migrate:
export default defineNuxtConfig({
experimental: {
nitroAutoImports: true,
},
})This applies only to the utilities Nitro and h3 provide. Your own exports from files directly in server/utils/ and shared/utils/ are still auto-imported.
Nested server/utils/ Files Are No Longer Auto-Imported
Nitro v2 auto-imported the exports of every file under server/utils/, including files in subdirectories. Nuxt 5 only scans the files directly in server/utils/, as it does for app/utils/ and shared/utils/. If server code uses an export from a nested file without importing it, the build warns with NUXT_B9006.
Re-export what you need from a file directly in server/utils/, or import it explicitly where it is used:
export { requireAdminSession } from './admin/oauth'To keep scanning subdirectories while you migrate, enable nitroLegacy.imports.
#imports Is Deprecated in Server Code, in Favor of #imports/server
Server code should import from #imports/server:
- import { defineEventHandler } from '#imports'
+ import { defineEventHandler } from '#imports/server'
export default defineEventHandler(() => ({ hello: true }))#imports still resolves when your server code runs, so an unmigrated project keeps working, but it is no longer typed: TypeScript reports it as unresolved until you move to #imports/server.
Server Imports Must Be Declared in package.json
An import that Nitro v3 can't resolve stays external, in development and in the build output, so nuxt dev fails at startup with Cannot find package 'ufo' imported from .nuxt/dev/index.mjs, and a built server fails on a route that reaches the import. Nitro v2 resolved such imports from Nuxt's own dependency tree.
Declare every package your server code imports in your package.json.
Error Handling: status/statusText replace statusCode/statusMessage
h3 v2 renames the error properties to align with Web standards:
createError({
- statusCode: 404,
- statusMessage: 'Not Found',
+ status: 404,
+ statusText: 'Not Found',
})In server routes, the error class is now HTTPError (replacing createError from h3):
- import { createError } from 'h3'
+ import { HTTPError } from 'nitro/h3'
export default defineEventHandler(() => {
- throw createError({ statusCode: 400, statusMessage: 'Bad request' })
+ throw new HTTPError({ status: 400, statusText: 'Bad request' })
})app/ directory), Nuxt's createError composable continues to work and is the recommended way to throw errors.createError No Longer Returns an HTTPError Instance
NuxtError is now its own class rather than a subclass of h3's HTTPError, so instanceof HTTPError no longer matches an error created with Nuxt's createError. Everything else is unchanged: the error keeps the same properties, serialises the same way, and is still mapped to the right HTTP response during SSR.
If you narrow errors by class, use one of the predicates instead:
- if (error instanceof HTTPError) {
+ if (HTTPError.isError(error)) {
// handles both `new HTTPError()` and Nuxt's `createError()`
}+ import { isNuxtError } from '#app'
+
+ if (isNuxtError(error)) {
+ // narrows to errors created with Nuxt's `createError`
+ }Server Event API Changes (h3 v2)
The H3Event object now uses Web standard APIs:
Request properties:
- event.path // string
+ event.url.pathname // URL object - use .pathname, .search, .hash
- event.method // string
+ event.req.method // via Web Request object
- event.node.req.headers // Node.js IncomingHttpHeaders
+ event.req.headers // Web Headers API (.get(), .set(), .has())Response properties:
- event.node.res.statusCode = 200
+ event.res.status = 200
- event.node.res.statusMessage = 'OK'
+ event.res.statusText = 'OK'
- setResponseHeader(event, 'x-custom', 'value')
+ event.res.headers.set('x-custom', 'value')
- appendResponseHeader(event, 'set-cookie', cookie)
+ event.res.headers.append('set-cookie', cookie)Server Middleware Runs for WebSocket Upgrades
Server middleware runs for a WebSocket upgrade request, which Nitro v2 didn't do. An error thrown there doesn't refuse the handshake. To refuse a handshake, return or throw a Response from the upgrade hook of the WebSocket handler.
useRuntimeConfig() No Longer Accepts event
In Nitro v3, useRuntimeConfig() no longer requires (or accepts) an event argument in server routes:
export default defineEventHandler((event) => {
- const config = useRuntimeConfig(event)
+ const config = useRuntimeConfig()
})The runtime config is now a single object shared by every request, both in server routes and in the Vue part of your app during server-side rendering. In Nuxt 4, each request received its own copy, so a change made while rendering one request (for example, setting runtimeConfig.public.siteUrl from the request host in a plugin) stayed within that request. In Nuxt 5, it is visible to every later request and, for public and app keys, to the browser through their payloads. Keep per-request values in useState, nuxtApp.payload or event.context instead. In development, Nuxt logs a warning when the runtime config is mutated while rendering a page.
Route Rules: statusCode Renamed to status
If you define redirect route rules, the property name has changed:
export default defineNuxtConfig({
routeRules: {
'/old-page': {
- redirect: { to: '/new-page', statusCode: 302 },
+ redirect: { to: '/new-page', status: 302 },
},
},
})Nuxt applies statusCode as status for now and warns, so an unmigrated rule keeps its status rather than silently falling back to the default. The fallback will be removed.
Cached Route Rules Ignore Query Parameters
Cached routes (cache, swr, isr) now key on the path only, and the query string is dropped before the handler runs. Set allowQuery to keep it, either as true or as a list of parameter names:
export default defineNuxtConfig({
routeRules: {
'/products': { cache: { swr: true, maxAge: 60, allowQuery: ['page'] } },
},
})The same applies to handlers wrapped in defineCachedHandler (or defineCachedEventHandler under nitroLegacy), including ones that modules register: getQuery(event) returns an empty object inside them. Pass allowQuery in the handler's options, or set a default for every cached handler with nitro.cache.defaults.allowQuery:
export default defineCachedHandler(event => listModules(getQuery(event)), {
maxAge: 60,
allowQuery: ['category', 'version'],
})Cached handlers and functions also store their entries under different keys (a custom getKey result is sanitised and suffixed with a hash), so a persistent cache starts cold after upgrading, and anything that reads cache entries by key needs updating. A cached handler or function that takes longer than 30 seconds to resolve now fails with a TimeoutError; set maxResolveTime (in seconds) where that is expected.
Route Rules: * Matches Nested Paths
Route rule patterns now follow the URLPattern syntax. A * matches any number of segments rather than exactly one, so a rule keyed /blog/* also applies to /blog/2026/hello. To match a single segment, use a named parameter:
export default defineNuxtConfig({
routeRules: {
- '/blog/*': { prerender: true },
+ '/blog/:slug': { prerender: true },
},
})A pattern can contain only one * or **, so a key such as /*/comments/** fails the build. Replace all but one of them with named parameters, for example /:post/comments/**.
Route Rules: Regex Constraints Can't Match Encoded Characters
Regex constraints in route rule patterns, such as /products/:id([a-z0-9]+), are matched against the percent-encoded path. The build fails if a constraint can match % or a character that is percent-encoded in a path, such as [é], a space, ., \S or a negated class like [^a-z], or if it uses a word boundary (\b or \B). List the characters a constraint allows instead, or use a parameter without a constraint (such as /products/:id) to match any value.
Route Rules: headers Apply After the Handler
Nitro v3 sets the headers of a headers route rule after the handler runs, so a rule header replaces a header of the same name that the handler sets, including one on a Response that the handler returns. This also applies to Nuxt 4 with Nitro v3, and the Nitro v2 compatibility layer doesn't change it.
Server Storage Is Renamed to KV
useStorage() from nitro/storage is now useKV() from nitro/kv, and the nitro.storage option is now nitro.kv. Mounts that only apply in development move from nitro.devStorage to nitro.kv under $development:
export default defineNuxtConfig({
- nitro: {
- storage: { redis: { driver: 'redis' } },
- devStorage: { redis: { driver: 'fs', base: './.data/redis' } },
- },
+ nitro: {
+ kv: { redis: { driver: 'redis' } },
+ },
+ $development: {
+ nitro: {
+ kv: { redis: { driver: 'fs', base: './.data/redis' } },
+ },
+ },
})The old names still work for now, with a deprecation warning.
Server File Names Can't Contain Unknown Suffixes
Nitro reserves dotted suffixes in the names of files it scans in server/, such as the .get in server/api/hello.get.ts. A file such as server/api/hello.world.ts fails the build (and is skipped with an error in development) unless the suffix is a known file extension, such as .json in server/routes/feed.json.ts. Rename the file, or add the suffix to nitro.scanSuffixes:
export default defineNuxtConfig({
nitro: {
scanSuffixes: ['world'],
},
})The build warns with NUXT_B9014 and lists the suffixes to add. Nitro v2 kept these suffixes as part of the name, so with nitroLegacy.config on, Nuxt adds them to nitro.scanSuffixes for you and lists the files with NUXT_B9013.
Route Rule Types Move to h3/rules
Nitro v3 builds route rules on h3, so custom route rules are declared there rather than on nitro/types. NitroRouteConfig and NitroRouteRules are still exported as deprecated aliases, but they are now type aliases rather than interfaces, so augmenting them fails with TS2300: Duplicate identifier.
There are two interfaces to declare, and they are separate on purpose. RouteRuleConfig is what a rule looks like in nuxt.config, and RouteRules is what a matched rule looks like at runtime:
- declare module 'nitropack/types' {
- interface NitroRouteConfig {
+ declare module 'h3/rules' {
+ interface RouteRuleConfig {
myModule?: { enabled: boolean }
}
- interface NitroRouteRules {
+ interface RouteRules {
myModule?: { enabled: boolean }
}
}A rule that nothing declares now reads back as unknown rather than any, so it needs a cast at the point of use:
- const enabled = rules.myUndeclaredRule
+ const enabled = rules.myUndeclaredRule as boolean | undefinedThe Server tsconfig.json Is Generated by Nuxt
Nuxt now generates .nuxt/tsconfig.server.json itself, as one of the tsconfigs it writes per environment, rather than delegating it to the server builder. If you extended it through Nitro, use the Nuxt option instead:
export default defineNuxtConfig({
- nitro: {
- typescript: {
- tsConfig: { compilerOptions: { /* ... */ } },
- },
- },
+ typescript: {
+ serverTsConfig: { compilerOptions: { /* ... */ } },
+ },
})typescript.serverTsConfig already existed in Nuxt 4 and was kept in sync with nitro.typescript.tsConfig, so this is a no-op if you were already using it.
For Module Authors: Additional Changes
- Nitro plugin imports: Use
import { definePlugin } from 'nitro', which is now required by default. See Server Auto-Imports Are Now Opt-In. - Route rule helpers:
basicAuthroute rules are replaced by middleware, and a newcorsrule replaces manual CORS wiring. See the Nitro migration guide for the runtime details. - Runtime hooks:
nitroApp.hooks.hook('beforeResponse', ...),nitroApp.hooks.hook('afterResponse', ...)andnitroApp.hooks.hook('render:response', ...)have been replaced bynitroApp.hooks.hook('response', ...). Therender:beforehook is emitted only while the Nitro v2 compatibility layer is active; to respond before a page renders, return aResponsefrom a server middleware. getRouteRules()fromnitro/app: On the server, the Nitro helper changed fromgetRouteRules(event)togetRouteRules(method, pathname), which returns{ routeRules }.
Removal of experimental.externalVue
🚦 Impact Level: Minimal
What Changed
The experimental.externalVue option has been removed. Vue compiler dependencies (@babel/parser, @vue/compiler-core, @vue/compiler-dom, @vue/compiler-ssr, estree-walker) are now always replaced with mock proxies in the server bundle when vue.runtimeCompiler is not enabled.
Reasons for Change
With the migration to Nitro v3, all dependencies are bundled into the server output by default (unlike Nitro v2, which externalized node_modules). The externalVue option was originally designed to keep Vue as an external dependency, which was needed to avoid multiple copies of Vue from being bundled, but since Nitro v3 bundles everything regardless, the option became a no-op.
Vue's server builds include the full compiler toolchain, pulling @babel/parser (465KB) and other compiler packages into the server bundle unnecessarily. These compiler packages are only needed when vue.runtimeCompiler is enabled for runtime template compilation.
By always mocking these compiler dependencies, the default server bundle size is reduced by approximately 860KB (~59%).
Migration Steps
If you previously set experimental.externalVue explicitly, you should now remove it.
export default defineNuxtConfig({
experimental: {
- externalVue: false,
},
})vue.runtimeCompiler: true, the real compiler packages are still included as before.Server-Only Head Composables Are No Longer Auto-Imported
🚦 Impact Level: Minimal
What Changed
useServerHead, useServerHeadSafe and useServerSeoMeta are removed from Nuxt's auto-imports. They are still exported from #app, so an explicit import keeps working.
The unhead.legacy option is ignored on Nuxt 5: setting it logs a warning. Unhead's legacy plugins (DeprecationsPlugin, PromisesPlugin, AliasSortingPlugin) are no longer registered, and Capo sorting is always on. TemplateParamsPlugin is still registered, so %s, %siteName and %separator title interpolation is unaffected.
These composables are no-ops on the client, and Nuxt tree-shakes them out of the client bundle in production builds.
Migration Steps
Wrap a useHead call in import.meta.server instead, or import the composable explicitly:
+ import { useServerHead } from '#app'
+
useServerHead({ meta: [{ name: 'generator', content: 'Nuxt' }] })Remove unhead.legacy from your configuration:
export default defineNuxtConfig({
- unhead: {
- legacy: true,
- },
})experimental.parseErrorData Is No Longer Configurable
🚦 Impact Level: Minimal
What Changed
The experimental.parseErrorData option is deprecated and forced on. Setting it to false logs a warning and is otherwise ignored, so error.data on the error page is always the value you passed to createError. There is no switch for this.
Reasons for Change
When Nuxt renders an error page it fetches /__nuxt_error internally, passing the error along with the request. That used to spread the error across one query parameter per field, and because query values are always strings, error.data arrived as a string and had to be parsed back. parseErrorData existed to opt out of that parsing.
The error is now sent as a single JSON-encoded parameter, so error.data keeps its original shape and is never stringified. Values also keep their types, so status is a number and booleans are booleans rather than the strings 'true' and 'false'. With nothing stringifying error.data, the option only survives to re-stringify it for apps that still expect a string.
Migration Steps
Remove the option:
export default defineNuxtConfig({
experimental: {
- parseErrorData: false,
},
})If you set it to false in order to keep parsing error.data yourself, drop that parsing too, as error.data now keeps whatever value you passed to createError:
<script setup lang="ts">
import type { NuxtError } from '#app'
const props = defineProps({
error: Object as () => NuxtError
})
- const data = JSON.parse(props.error.data)
+ const data = props.error.data
</script>Error Format Depends on Where the Error Is Thrown
🚦 Impact Level: Moderate
What Changed
An error thrown while rendering a page returns the HTML error page. An error thrown in a server route or server middleware returns JSON. The Accept, Sec-Fetch-Mode, and User-Agent request headers and the /api/ path prefix no longer affect the format.
Compared with Nuxt 4:
- Page errors return the HTML error page with the error's status code, even for requests that accept JSON. This includes
fetch()and$fetch()calls in the browser,curl, and requests with anAccept: application/jsonheader. - Server route and server middleware errors return JSON, even for a browser navigation. This includes server middleware that throws for a page route, such as an authentication check.
- Payload errors for
_payload.jsonrequests still return JSON.
Reasons for Change
In Nuxt 4, the request headers determined the error format, so one URL could return a different error response to each kind of client. Caches had to vary on those headers. A fetch() call to a page also returned JSON, while navigating to the same page returned HTML. Each URL now has a single error response.
Migration Steps
If you read the JSON body of a failed page request, such as error.data from $fetch('/some-page'), read the response status instead. To keep structured error data, move it into a server route.
If server middleware throws for page routes to show the error page, move the check into route middleware. Route middleware runs during the page render, so an error it throws returns the error page:
export default defineNuxtRouteMiddleware((to) => {
if (to.path.startsWith('/admin') && !useCookie('session').value) {
throw createError({ status: 401, statusText: 'Unauthorized' })
}
})To restore the Nuxt 4 behavior, disable experimental.inlineErrorRendering. This also restores the Nuxt 4 way of rendering the error page, through an internal request to /__nuxt_error:
export default defineNuxtConfig({
experimental: {
inlineErrorRendering: false,
},
})Removed Configuration Options
🚦 Impact Level: Minimal
What Changed
Three experimental options are removed, because the behavior they controlled is now unconditional in Nuxt 5:
experimental.viteEnvironmentApi. See Migration to Vite Environment API.experimental.routeTypedFetch. See Typed$fetchRebuilt on Generated Route Types.experimental.renderJsonPayloads. Payloads are always rendered and parsed as JSON, with support for revivers.
experimental.externalVue is removed too, which is covered in its own section.
Migration Steps
Remove the options from your configuration:
export default defineNuxtConfig({
experimental: {
- viteEnvironmentApi: true,
- routeTypedFetch: true,
- renderJsonPayloads: true,
},
})@vitejs/plugin-vue-jsx Is Now Optional
🚦 Impact Level: Minimal
What Changed
@vitejs/plugin-vue-jsx is no longer installed by default with @nuxt/vite-builder. It is now an optional peer dependency that is loaded on demand only when a .jsx or .tsx file is encountered during the build.
If your project uses JSX/TSX components, Nuxt will automatically detect this and prompt you to install the package.
Reasons for Change
The @vitejs/plugin-vue-jsx plugin pulls in a significant dependency tree (Babel, @vue/babel-plugin-jsx, etc.) that is unnecessary for projects that don't use JSX. Making it optional reduces the default install size and speeds up dependency resolution for the majority of Nuxt projects.
Migration Steps
If your project uses .jsx or .tsx files, add @vitejs/plugin-vue-jsx as a dev dependency:
npm install -D @vitejs/plugin-vue-jsxyarn add -D @vitejs/plugin-vue-jsxpnpm add -D @vitejs/plugin-vue-jsxbun add -D @vitejs/plugin-vue-jsxAlternatively, Nuxt will prompt you to install it automatically the first time a JSX/TSX file is processed during development.
If your project does not use JSX, no changes are needed.
PostCSS Plugins Are No Longer Installed by Default
🚦 Impact Level: Medium
What Changed
autoprefixer and cssnano are no longer configured by default, and are no longer dependencies of @nuxt/vite-builder. They are optional peer dependencies, applied only when you name them in postcss.plugins. Vite minifies CSS as part of the build, so cssnano is not needed for that.
The webpack and rspack builders still configure both, along with postcss-import and postcss-url.
Reasons for Change
Both packages were installed for every project to run a pass most projects do not configure, and browser support for the properties autoprefixer prefixes has moved on since the default was set.
Migration Steps
If you need either plugin, install it and enable it explicitly:
npm install -D autoprefixer cssnanoyarn add -D autoprefixer cssnanopnpm add -D autoprefixer cssnanobun add -D autoprefixer cssnanoexport default defineNuxtConfig({
postcss: {
plugins: {
autoprefixer: {},
cssnano: {},
},
},
})If a configured plugin is not installed, Nuxt prompts you to install it and reports the command to run.
giget Is Now Optional (Remote Layers)
🚦 Impact Level: Minimal
What Changed
giget is no longer installed by default. It is now an optional peer dependency of @nuxt/kit, needed only to download a layer that extends names by remote URL:
export default defineNuxtConfig({
extends: ['github:my-org/my-theme'],
})Local layers, layers in ~~/layers/, and layers installed as packages are unaffected.
Reasons for Change
Most projects never extend from a remote source, so the downloader was being installed for everyone to serve a small minority. Downloading a layer at config-resolution time is also the least reproducible way to consume one: the fetch happens outside your package manager, so it is not in your lockfile and, unless you pin it yourself, not pinned to a revision.
Migration Steps
Preferred: move the layer into package.json. Every major package manager understands git URLs, so a remote layer can be a normal dependency. This puts it in your lockfile, pins it to an exact commit, and installs it alongside everything else:
{
"devDependencies": {
"my-theme": "github:my-org/my-theme#4a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b"
}
}Then extend from it by package name:
export default defineNuxtConfig({
extends: ['my-theme'],
})The part after # is any commit-ish, so a tag (#v1.2.0) or #semver:^1.2.0 works too; a full commit SHA is the only form that is genuinely immutable.
Otherwise, install giget and keep using a remote extends entry:
npm install -D gigetyarn add -D gigetpnpm add -D gigetbun add -D gigetIf a remote layer is resolved without giget present, Nuxt reports which extends entry needs it.
vue and vue-router Are Peer Dependencies
🚦 Impact Level: Minimal
What Changed
nuxt no longer installs its own copy of vue and vue-router. Both are peer dependencies, and Nuxt builds and runs your app with the copy your project installs. vue-router is optional, and only needed when pages are enabled (for example, when your app has a pages/ directory or sets pages: true).
Nuxt warns at startup if the installed vue or vue-router does not satisfy the range it supports.
Reasons for Change
Vue keeps its rendering state per copy, so every component in an app has to use the same copy of Vue. Taking vue from your project means Nuxt, your app and your modules all share the copy you install.
Migration Steps
New Nuxt projects have listed vue and vue-router in their package.json for a long time, so most projects need no changes. If yours does not, Nuxt prompts you to install vue when it starts, and vue-router when pages are enabled. Nuxt requires vue-router v5, so if your package.json still lists vue-router@^4, upgrade it as well (see the Vue Router migration guide). You can also add them yourself:
npm install vue vue-routeryarn add vue vue-routerpnpm add vue vue-routerbun add vue vue-routerBuild-Time Proxy Support Uses Node.js
🚦 Impact Level: Minimal (Medium if you build behind a proxy)
What Changed
When HTTPS_PROXY or HTTP_PROXY (or their lowercase forms) is set, Nuxt relies on Node's built-in proxy support to route build-time requests from modules, prerendering and your nuxt.config through the proxy. Hosts listed in NO_PROXY are reached directly.
- Node.js 24 and 26: Nuxt calls Node's
http.setGlobalProxyFromEnv(), so requests made withnode:httpandnode:httpsuse the proxy as well asfetch. Node replaceshttp.globalAgentwhenHTTP_PROXYis set andhttps.globalAgentwhenHTTPS_PROXYis set, so a global agent assigned beforeloadNuxtruns (for example, in a script that runs Nuxt programmatically) is replaced. Agents that modules assign during setup are kept. - Node.js 22: Nuxt no longer depends on
undici, so it does not installEnvHttpProxyAgentas Nuxt 4 did. Unless Node's own proxy support is on, build-time requests go directly to their destination, and Nuxt logs a warning when a proxy variable is set.
Nuxt leaves the proxy configuration alone when NODE_USE_ENV_PROXY=0 is set, when Node's own proxy support is already on (NODE_USE_ENV_PROXY=1 or --use-env-proxy), or when a global dispatcher other than undici's default Agent is installed, such as a ProxyAgent. On Node.js 24 and 26, a global dispatcher that is itself an undici Agent (for example, one created with custom TLS options) cannot be distinguished from the default one, and is replaced.
Migration Steps
If you build behind a proxy on Node.js 22, set NODE_USE_ENV_PROXY=1 alongside your proxy variables, which routes fetch, node:http and node:https through the proxy, or upgrade to Node.js 24:
NODE_USE_ENV_PROXY=1 HTTPS_PROXY=http://proxy.example.com:8080 npx nuxt buildIf you build behind a proxy on Node.js 24 or 26 and a module reaches internal hosts with node:http or node:https, add those hosts to NO_PROXY:
HTTPS_PROXY=http://proxy.example.com:8080 NO_PROXY=internal.example.com npx nuxt buildDepending on the Node.js version, fetch and node:http match IPv6 addresses in NO_PROXY in different forms, so list each one both bare and in brackets:
HTTPS_PROXY=http://proxy.example.com:8080 NO_PROXY=localhost,::1,[::1] npx nuxt buildTo keep a custom global agent or an undici Agent dispatcher, or to opt out of proxy support entirely (which also silences the warning on Node.js 22), set NODE_USE_ENV_PROXY=0.
Removal of Legacy _renderResponse Support
🚦 Impact Level: Minimal
What Changed
ssrContext._renderResponse is no longer checked as a fallback. Only the internal ssrContext['~renderResponse'] (set by Nuxt's own router composable) is used.
Reasons for Change
The _renderResponse property on ssrContext was kept as a backward-compatibility fallback after #33896 migrated the internal API to ~renderResponse. The TODO comments indicated it should be removed in Nuxt v5.
Migration Steps
If you were setting ssrContext._renderResponse directly (which was never a public API), use ssrContext['~renderResponse'] instead. The Nuxt router composable already uses the new property, so no changes are needed if you're going through navigateTo or route middleware.
Non-Async callHook
🚦 Impact Level: Minimal
What Changed
With the upgrade to hookable v6, callHook may now return void instead of always returning Promise<void>. This is a significant performance improvement that avoids unnecessary Promise allocations when there are no registered hooks or all hooks are synchronous.
Nuxt 4 wrapped callHook with Promise.resolve() so that existing .then() and .catch() chaining continued to work. That wrapper is removed, and experimental.asyncCallHook now defaults to false.
Reasons for Change
Hookable v6's callHook is 20-40x faster because it avoids creating a Promise when one is not needed. This benefits applications with many hook call sites.
Migration Steps
If you or your modules use callHook with .then() or .catch() chaining, switch to await:
- nuxtApp.callHook('my:hook', data).then(() => { ... })
+ await nuxtApp.callHook('my:hook', data)- nuxtApp.hooks.callHook('my:hook', data).catch(err => { ... })
+ try { await nuxtApp.hooks.callHook('my:hook', data) } catch (err) { ... }To keep callHook always returning a Promise:
export default defineNuxtConfig({
experimental: {
asyncCallHook: true,
},
})Client-Only Comment Placeholders
🚦 Impact Level: Minimal
What Changed
Client-only components (.client.vue files and createClientOnly() wrappers) now render an HTML comment (<!--placeholder-->) on the server instead of an empty <div> element.
Reasons for Change
When the placeholder <div> and the actual component root share the same tag name, Vue's runtime skips re-applying setScopeId during hydration. This causes scoped styles to be missing after the component mounts. Using a comment node avoids the tag name collision entirely.
Migration Steps
If you rely on the placeholder <div> to inherit attributes (class, style, etc.) for layout purposes (e.g., reserving space to prevent layout shift), wrap the component in <ClientOnly> with a #fallback slot instead:
- <MyComponent class="placeholder" style="min-height: 200px" />
+ <ClientOnly>
+ <MyComponent />
+ <template #fallback>
+ <div class="placeholder" style="min-height: 200px"></div>
+ </template>
+ </ClientOnly>To revert to the previous <div> placeholder behavior:
export default defineNuxtConfig({
experimental: {
clientNodePlaceholder: false,
},
})Stricter Side-Effect Imports
🚦 Impact Level: Minimal
What Changed
Nuxt's generated tsconfig.json enables noUncheckedSideEffectImports. This is a default in TypeScript 7, so adopting it early keeps your project aligned ahead of that upgrade.
With this option on, a side-effect-only import (import './setup') that TypeScript cannot resolve to a module is now a type error, whereas it was previously ignored. This only affects type-checking (nuxt typecheck and your editor), not runtime behavior.
Reasons for Change
Unresolved side-effect imports were silently ignored, so a typo or a deleted file could pass type-checking. Flagging them catches these mistakes and matches the TypeScript 7 default.
Migration Steps
If type-checking now errors on a side-effect import of a non-code asset (for example import '~/assets/styles.css'), add an ambient module declaration so TypeScript knows the import is valid:
declare module '*.css' {}You can revert to the previous behavior by disabling the option in your nuxt.config:
export default defineNuxtConfig({
typescript: {
tsConfig: {
compilerOptions: {
noUncheckedSideEffectImports: false,
},
},
},
})Vue Options API Disabled by Default
🚦 Impact Level: Minimal
What Changed
Nuxt sets Vue's __VUE_OPTIONS_API__ feature flag to false, which compiles Vue's Options API runtime out of the client bundle.
Reasons for Change
The Options API runtime ships in every client bundle even though most Nuxt applications are written with the Composition API and <script setup>. Dropping it shrinks the client bundle (around 6 kB minified / 2 kB gzipped on a minimal app).
Migration Steps
If any of your components (or a dependency's components) use the Options API (export default { data() {}, methods: {}, ... }), re-enable it in your nuxt.config:
export default defineNuxtConfig({
vue: {
optionsApi: true,
},
})defineNuxtComponent is unaffected: its asyncData and head options are handled through setup() rather than the Vue Options API, so it works regardless of this flag.Typed Pages Enabled by Default
🚦 Impact Level: Minimal
What Changed
experimental.typedPages is now enabled by default. Nuxt generates typed route names and paths from your pages/ directory, so composables like useRoute, navigateTo, <NuxtLink> and router.push are type-checked against your actual routes.
Reasons for Change
Typed routing catches broken links and stale route names at type-check time rather than at runtime, and it is now native to vue-router, so it is a sensible default.
Migration Steps
If you reference routes that don't exist (for example a typo in a to prop, or a route defined dynamically outside the pages/ directory), type-checking will now error. Fix the reference, or extend the generated route types for routes you add at runtime.
To opt out and revert to the previous behavior:
export default defineNuxtConfig({
experimental: {
typedPages: false,
},
})Typed $fetch Rebuilt on Generated Route Types
🚦 Impact Level: Medium
What Changed
$fetch and useFetch are typed from the routes Nuxt's server builder reports, rather than from
nitro's InternalApi interface. As well as response types, a body, query or headers the
matching handler validates are now enforced on the call, and a method the route does not handle is
rejected.
Two things follow from this:
- Routes you augmented by hand on nitro's
InternalApiare no longer picked up. AugmentServerRoutesfrom@nuxt/schemainstead. - The
paramsoption is no longer accepted by$fetchoruseFetch. It was an alias forquery.
A route written with defineCachedHandler, or with defineCachedEventHandler or cachedEventHandler, is typed by what the handler it caches returns. Called directly, a cached handler resolves to the Response it serves.
A path the generated route types do not describe still resolves, as unknown, unless you opt in to experimental.strictRouteTypes.
Reasons for Change
Nitro v3 dropped typed fetch, and the old implementation did not scale past about 300 routes. The new
generated route types cost the same to check whatever the route count, and carry enough information to type the
request as well as the response. params is dropped so the name is free for named route parameters
later.
Migration Steps
Move any params option to query:
const { data } = await useFetch('/api/search', {
- params: { q: 'nuxt' },
+ query: { q: 'nuxt' },
})Move any manual route augmentation from InternalApi to ServerRoutes:
- declare module 'nitropack' {
- interface InternalApi {
- '/api/hello': { get: { message: string } }
- }
- }
+ import type { Endpoint } from 'nuxt/app'
+
+ declare module '@nuxt/schema' {
+ interface ServerRoutes {
+ '/api/hello': {
+ [Endpoint]: {
+ GET: { response: { message: string } }
+ }
+ }
+ }
+ }Replace options typed as Parameters<typeof $fetch>[1]. With nitropack, that type is nitropack's
NitroFetchOptions, which accepts any method and ofetch's own option types. With Nitro v3, $fetch
is typed from your app's routes, and the type read off its signature isn't one it accepts for a
string URL: depending on your routes, it resolves to never or to options that a call with a
string URL rejects.
For a URL your app doesn't serve, where you name the response type, type the options as
FetchOptions from nuxt/app (or from #app in app code). This is Nuxt's type: ofetch's type of
the same name types method as a plain string, which typed $fetch doesn't accept, so a file that
already imports ofetch's FetchOptions needs to alias one of the two. Server code that calls ofetch's
own $fetch keeps ofetch's own options type: Nuxt's FetchOptions is for Nuxt's typed $fetch.
+ import type { FetchOptions } from 'nuxt/app'
+
- export function fetchRegistry<T> (url: string, options: Parameters<typeof $fetch>[1] = {}) {
+ export function fetchRegistry<T> (url: string, options: FetchOptions = {}) {
return $fetch<T>(url, options)
}For a wrapper around your own routes with different defaults, use $fetch.create, which keeps the
route typing:
- export function api<T> (url: string, options: Parameters<typeof $fetch>[1] = {}) {
- return $fetch<T>(url, { ...options, headers: { 'x-client': 'app' } })
- }
+ export const api = $fetch.create({ headers: { 'x-client': 'app' } })$fetch Is No Longer a Global in the Browser
🚦 Impact Level: Minimal
What Changed
The client build no longer sets globalThis.$fetch. Code that calls $fetch receives it as an import from #build/fetch, including code that does not use auto-imports, such as module runtime files. On the server, globalThis.$fetch is still set.
Reasons for Change
An app that never calls $fetch no longer ships ofetch to the browser.
Migration Steps
If you read or replace globalThis.$fetch in the browser, use a plugin that provides your own instance instead:
export default defineNuxtPlugin(() => {
- globalThis.$fetch = $fetch.create({ baseURL: '/api' })
+ return {
+ provide: {
+ api: $fetch.create({ baseURL: '/api' }),
+ },
+ }
})Then call useNuxtApp().$api wherever you used the replaced global.
TypeScript baseUrl Is Ignored
🚦 Impact Level: Minimal
What Changed
Nuxt removes compilerOptions.baseUrl from its generated TypeScript configurations. Relative Nuxt and Nitro aliases are resolved from Nuxt's build directory instead of a custom baseUrl.
Reasons for Change
TypeScript 6 deprecates baseUrl, and it is no longer required when using paths. Removing the option also keeps Nuxt's generated aliases anchored consistently to the generated configuration that contains them.
Migration Steps
Remove baseUrl from your Nuxt TypeScript configuration. If you used it to anchor a relative Nuxt or Nitro alias, make that alias absolute instead:
+ import { fileURLToPath } from 'node:url'
+
export default defineNuxtConfig({
alias: {
- images: './assets/images',
+ images: fileURLToPath(new URL('./assets/images', import.meta.url)),
},
- typescript: {
- tsConfig: {
- compilerOptions: {
- baseUrl: '..',
- },
- },
- },
})Nitro v2 Compatibility
The Nitro v3 changes listed above cover a lot of server code. You don't have to work through all of them before Nuxt 5 will build. Nuxt 5 includes a compatibility layer that runs older server code as it is, so you can upgrade first and migrate afterwards.
Module Server Code
Modules are covered automatically. If a module's server files import from h3, nitropack, #internal/nitro or #imports, Nuxt gives that module what its code expects: the h3 v1 helpers, the old nitropack paths mapped to Nitro v3, useRuntimeConfig(event), and the v1 event properties.
The build tells you which modules this happened to:
WARN [NUXT_B9003] Nitro v2 compatibility was applied to server code from 1 module, because of what it imports:
- some-module (imports `h3`, `nitropack/runtime`)You don't need to do anything about this notice. It's aimed at the module's author, and it's a sign that a later release of that module will no longer need the layer.
Your Own server/ Directory
Your own server code is not covered by default, because the errors you get are what show you where the work is. When nitroLegacy is off, NUXT_B9005 lists the files in your server/ directory that import from nitropack, import h3 v1 helpers that h3 v2 no longer exports, or read event.node. If your project depends on h3 v1 itself, h3 imports in your server code resolve to it rather than to h3 v2, and NUXT_B9009 lists the files importing from h3 until you remove the dependency or turn on nitroLegacy.h3. If you want to ship the upgrade before doing that work, turn on nitroLegacy:
export default defineNuxtConfig({
nitroLegacy: true,
})With it on, import { defineEventHandler, getQuery } from 'h3', useRuntimeConfig(event), defineNitroPlugin, cachedEventHandler, useEvent, auto-imports from subdirectories of server/utils/, handlers registered without a route, and server files with a dotted suffix in their names, such as server/middleware/auth.global.ts, all keep working. A handler that returns a string still sends it as text/html unless it sets a content type, and a handler that returns null still responds with 204 No Content, or with the status it set.
The h3 v1 helpers that ended the response still end it. When a handler defined with defineEventHandler calls sendRedirect, sendNoContent, send, sendStream, sendError, sendProxy or sendWebResponse, or handles a preflight request with handleCors, Nuxt sends that response even if the handler returns nothing, and the request goes no further. A handler defined with defineEventHandler({ handler, websocket }) still gets its websocket hooks for a WebSocket upgrade request. The onRequest hooks of such a handler run for the requests it responds to, and not for its WebSocket upgrade request.
With nitroLegacy.h3 on, Nuxt also removes any server alias that points h3 at h3 v1, such as one a module sets so that h3 resolves to the copy nitropack depends on, and reports it with NUXT_B9015. Nitro v3 can't run h3 v1, so with the alias removed, Nitro v2 code gets the h3 v1 helpers and other server code gets h3 v2.
Each part is a separate switch, so you can migrate one at a time:
export default defineNuxtConfig({
nitroLegacy: {
h3: true, // `h3` resolves to the h3 v1 helpers
specifiers: true, // `nitropack`, `nitropack/runtime`, `#internal/nitro`
runtimeConfig: true, // the `useRuntimeConfig(event)` signature
imports: false, // the Nitro v2 auto-import names, and nested `server/utils/` files
config: false, // Nitro v2 config shapes and dotted server file names
},
})The beforeResponse, afterResponse, render:before and render:response hooks need no switch. Whenever the layer is active, for your code or for a module's, Nuxt emits beforeResponse and afterResponse from the Nitro v3 response hook, and render:before and render:response around each page render. It reports any case it can't handle. Nitro v2 plugins that the layer covers, and useNitroApp() imported from nitropack/runtime, also get a nitroApp.hooks.callHook() that always returns a promise, as in Nitro v2, so callHook('my-hook').catch(...) keeps working.
On Nuxt 4 with Nitro v3, when nitroLegacy.config is on, error responses carry the x-content-type-options: nosniff, x-frame-options: DENY and referrer-policy: no-referrer headers, and JSON error responses also carry content-security-policy: script-src 'none'; frame-ancestors 'none';. On Nuxt 5, and on Nuxt 4 with nitroLegacy.config off, Nuxt doesn't add these headers to error responses.
With nitroLegacy.config on, build hooks such as prerender:done can read and write the Nitro v2 build-time storage, nitro.storage. It has the root:, src:, build: (your buildDir), cache: and data: mounts, plus the ones you declare in nitro.kv and nitro.devStorage. The dev server and the prerenderer get the same build:, cache: and data: mounts, so what the prerenderer writes to build: can be read from nitro.storage once prerendering is done. Your production server doesn't get them. Unlike Nitro v2, cached handlers and functions keep the memory cache driver in development and while prerendering, unless you set nitro.cache.driver or declare a cache mount yourself.
What the Layer Doesn't Cover
- Undeclared dependencies.
nitropackv2 put its own dependencies into the server bundle, so a file could import something likelru-cachewithout depending on it and still work. Add the package to your own dependencies, or report it to the module that needs it. - Types. The layer mostly changes how your server code runs, not how it type-checks. With
nitroLegacy.specifiers, an augmentation ofnitropackornitropack/types, in your code or a module's, applies to the Nitro v3 interface of the same name, such asNitroRuntimeHooks. Augmentations ofnitropack/runtimeand#internal/nitroare not picked up, and route rules are declared elsewhere (see Route Rule Types Move toh3/rules). WithnitroLegacy.h3,h3resolves to Nitro's h3 v2 in the server tsconfig, even if your project depends on h3 v1, so anH3Eventimported fromh3matches the event your handlers receive. On that type,event.nodeis optional. Helpers that only h3 v1 has, such assend,sendErrororisStream, still work when imported fromh3, but they don't type-check that way. Their auto-imports are typed.useRuntimeConfig(event)in a server route is still reported, because typed$fetchresponses check route files alongside your app code. For the same reason, anH3Eventfromh3in a server route is still reported by the app tsconfig, which resolvesh3to your project's dependency. - The event object. With the default builder,
eventis h3 v2's event. The layer adds back some things h3 v2 dropped, such asevent.context.nitro,event.context._nitro.routeRulesand a Node-shapedevent.nodeon runtimes that don't have one. Requests made in process, such as a server-side$fetchoruseFetchto one of your own routes or a page being prerendered, get one too, with anevent.node.req.socketwhosereadyStateis'readOnly', as in Nitro v2. ItsremoteAddressis the client address of the request that made the call, orundefinedwhen there is none. Headers and the status you set onevent.node.resapply to the response that Nitro sends. - The
closehook while prerendering. Nitro v3 stops the prerenderer without calling the runtimeclosehook, so a listener that saves data there never runs, and the data is lost. Nuxt names each Nitro v2 plugin that registers one withNUXT_E8017. Save the data as each route is prerendered instead, and read it back in a build hook.
Migration Steps
- Upgrade, build, and read the notices.
NUXT_B9003is about modules, so it's their authors' work rather than yours. Errors in your ownserver/directory are yours. - Move your server imports to
nuxt/server, which is available from Nuxt 4.6, and move anything it doesn't cover tonitro/h3ornitro/*. LeavenitroLegacyoff while you do this. - Turn on
nitroLegacyonly if you need to ship before you've finished. Then set one switch tofalseat a time and fix what breaks, until you can remove the option. - If a module is still named by
NUXT_B9003, check for a newer release, and open an issue if there isn't one.