🐞 Bug Fixes
- Downgrade
@eslint/js, fix #647 - by @antfu in https://github.com/nuxt/eslint/issues/647 (2c1c1)
@eslint/js, fix #647 - by @antfu in https://github.com/nuxt/eslint/issues/647 (2c1c1)4.3.1 is a regularly scheduled patch release.
x-nitro-prerender header (#34202)server/ for builder:watch hook (#34208)error.message for fatal errors (#34226)#app barrel export in keyed functions (#34199)datetime in nuxt/schema (#34255)meta.name (#34263)#components import mapping conflict for packages outside rootDir (#34139)nuxt/schema once more (552bbd8d1)genObjectKey to omit unnecessary quotes (#34245)ComponentProps helper to extract layout props (#34248)nitroAutoImports (#34182)#server and rootDir (#34259)keyedComposables (#34201)<NuxtPage> navigation (048efc030)3.21.1 is a regularly schedule patch release.
server/ for builder:watch hook (#34208)x-nitro-prerender header (#34202)error.message for fatal errors (#34226)#app barrel export in keyed functions (#34199)datetime in nuxt/schema (#34255)meta.name (#34263)#components import mapping conflict for packages outside rootDir (#34139)nuxt/schema once more (9f5bb611d)genObjectKey to omit unnecessary quotes (#34245)ComponentProps helper to extract layout props (#34248)keyedComposables (#34201)<NuxtPage> navigation (707a9dc44)4.0.0 is the next major release.
We're releasing Nuxt Test Utils v4, with support for Vitest v4. 🚀
The biggest improvement in this release is how mocking works. Nuxt initialization has been moved from setupFiles to the beforeAll hook (#1516), which means vi.mock and mockNuxtImport calls now take effect before Nuxt starts. This fixes a long-standing issue where mocks for composables used in middleware or plugins wouldn't apply reliably (#750, #836, #1496).
On top of that, mockNuxtImport now passes the original implementation to the factory function (#1552), making partial mocking much more natural:
mockNuxtImport('useRoute', original => vi.fn(original))
it('my test', async () => {
vi.mocked(useRoute).mockImplementation(
(...args) => ({ ...vi.mocked(useRoute).getMockImplementation()!(...args), path: '/mocked' }),
)
const wrapper = await mountSuspended(MyComponent)
expect(wrapper.find('#path').text()).toBe('/mocked')
})
registerEndpoint improvementsregisterEndpoint now works correctly with query parameters in URLs (#1560), and endpoints registered in setup files are no longer lost when modules reset (#1549).
@nuxt/test-utils v4 contains a few breaking changes, almost all related to requiring at least vitest v4 as a peer dependency (if you are using vitest). It replaces vite-node with Vite's native Module Runner and simplifies pool configuration.
This will mean improvements for test performance and mocking, but does require some changes to your test code.
!TIP Most of the changes below are straightforward. The biggest thing to watch out for is code that runs at the top level of a
describeblock — see below.
Update vitest and its companion packages together:
{
"devDependencies": {
- "@nuxt/test-utils": "^3.x",
- "vitest": "^3.x",
- "@vitest/coverage-v8": "^3.x"
+ "@nuxt/test-utils": "^4.0",
+ "vitest": "^4.0",
+ "@vitest/coverage-v8": "^4.0"
}
}
We've tightened peer dependency ranges. You may need to update some of these:
| Dependency | v3 | v4 |
|---|---|---|
vitest | ^3.2.0 | ^4.0.2 |
happy-dom | * | >=20.0.11 |
jsdom | * | >=27.4.0 |
@jest/globals | ^29.5.0 || >=30.0.0 | >=30.0.0 |
@cucumber/cucumber | ^10.3.1 || >=11.0.0 | >=11.0.0 |
@testing-library/vue | ^7.0.0 || ^8.0.1 | ^8.0.1 |
This is the change that might require most change in your tests. Because we've moved the nuxt environment setup into beforeAll, this means composables called at the top level of a describe block will fail with [nuxt] instance unavailable.
// Before (worked in vitest v3)
describe('my test', () => {
const router = useRouter() // ran lazily, after environment setup
// ...
})
// After (vitest v4)
describe('my test', () => {
let router: ReturnType<typeof useRouter>
beforeAll(() => {
router = useRouter() // runs after environment setup
})
// ...
})
This applies to useRouter(), useNuxtApp(), useRoute(), and any other Nuxt composable or auto-import.
!TIP If you only need the value within individual tests,
beforeEachor directly within the test works too.
If you use vi.mock with a factory function, accessing an export that the factory doesn't return will now throw an error instead of silently returning undefined.
// Before: accessing `bar` would silently return undefined
vi.mock('./module', () => ({ foo: 'mocked' }))
// After: accessing `bar` throws
// Fix: use importOriginal to include all exports
vi.mock('./module', async (importOriginal) => ({
...await importOriginal(),
foo: 'mocked',
}))
!NOTE If you're mocking a virtual module (like
#build/nuxt.config.mjs) whereimportOriginalcan't resolve the real module, you might need to explicitly list all accessed exports in your mock factory.
For the full list, see the vitest v4 migration guide.
mockNuxtImport factory (#1552)beforeAll hook (#1516)registerEndpoint with query params (#1560)nextTick import (#1563)@nuxt/devtools-kit for devtools hooks (426e0b537)app-vitest follow advised setup guidelines (#1542).nuxtrc (b4021dee4)beforeAll hook (#1516)no-page-meta-runtime-values - by @danielroe in https://github.com/nuxt/eslint/issues/641 (b74a0)contentRawMarkdown - by @farnabaz (5be6b)eslint-flat-config-utils eslint-plugin-import-lite and eslint-plugin-jsdoc - by @antfu (10bf9)See https://github.com/nuxt/scripts/issues/594, please provide issues there.
4.3.0 is the next minor release.
Nuxt 4.3 brings powerful new features for layouts, caching, and developer experience – plus significant performance improvements under the hood.
Early this month, I opened a discussion to find out how the upgrade had gone from v3 to v4. I was really pleased to hear how well it had gone for most people.
Having said that, we're committed to making sure no one gets left behind. And so we will continue to provide security updates and critical bug fix releases beyond the previously announced end-of-life date of January 31, 2026, meaning Nuxt v3 will meet its end-of-life on July 31, 2026.
!TIP As usual, today also brings a minor release for v3, with many of the same improvements backported from v4.3.
We're closer than ever to the releases of Nuxt v5 and Nitro v3. In the coming weeks, the main branch of the Nuxt repository will begin receiving initial commits for Nuxt 5. However, it's still business as usual.
main branch4.x and 3.x branchesKeep an eye out on the Upgrade Guide – we'll be adding details about how you can already start migrating your projects to prepare for Nuxt v4 with future.compatibilityVersion: 5.
But that's enough about the future. We have a lot of good things for you today!
First, you can now set layouts directly in route rules using the new appLayout property (#31092). This provides a centralized, declarative way to manage layouts across your application without scattering definePageMeta calls throughout your pages.
export default defineNuxtConfig({
routeRules: {
'/admin/**': { appLayout: 'admin' },
'/dashboard/**': { appLayout: 'dashboard' },
'/auth/**': { appLayout: 'minimal' }
}
})
This might be useful for:
!TIP Plus, you can pass props to layouts now! See the
setPageLayoutimprovements below.
Payload extraction now works with ISR (incremental static regeneration), SWR (stale-while-revalidate) and cache routeRules (#33467). Previously, only pre-rendered pages could generate _payload.json files.
This means:
export default defineNuxtConfig({
routeRules: {
'/products/**': {
isr: 3600, // Revalidate every hour
}
}
})
Related to the above, payload extraction now also works in development mode (#30784). This makes it easier to test and debug payload behavior without needing to run a production build.
!IMPORTANT Payload extraction works in dev mode with
nitro.staticset totrue, or for individual pages which haveisr,swr,prerenderorcacheroute rules.
When extending Nuxt layers, you can now disable specific modules that you don't need (#33883). Just pass false to the module's options:
export default defineNuxtConfig({
extends: ['../shared-layer'],
// disable @nuxt/image from layer
image: false,
})
Route groups (folders wrapped in parentheses like (protected)/) are now exposed in page meta (#33460). This makes it easy to check which groups a route belongs to in middleware or anywhere you have access to the route.
<script setup lang="ts">
// This page's meta will include: { groups: ['protected'] }
useRoute().meta.groups
</script>
export default defineNuxtRouteMiddleware((to) => {
if (to.meta.groups?.includes('protected') && !isAuthenticated()) {
return navigateTo('/login')
}
})
This provides a clean, convention-based approach to route-level authorization without needing to add definePageMeta to every protected page.
setPageLayoutThe setPageLayout composable now accepts a second parameter to pass props to your layout (#33805):
export default defineNuxtRouteMiddleware((to) => {
setPageLayout('admin', {
sidebar: true,
theme: 'dark'
})
})
<script setup lang="ts">
defineProps<{
sidebar?: boolean
theme?: 'light' | 'dark'
}>()
</script>
#server AliasA new #server alias provides clean imports within your server directory (#33870), similar to how #shared works:
// Before: relative path hell
import { helper } from '../../../../utils/helper'
// After: clean and predictable
import { helper } from '#server/utils/helper'
The alias includes import protection – you can't accidentally import #server code from client or shared contexts.
The development error overlay introduced in Nuxt 4.2 is now draggable and can be minimized (#33695). You can:
This is a quality-of-life improvement when you're iterating on fixes and don't want the overlay blocking your view.
https://github.com/user-attachments/assets/nuxt_4-3_error_demo.mp4
Module authors can now use async functions when adding build plugins (#33619):
export default defineNuxtModule({
async setup() {
// Lazy load only when actually needed
addVitePlugin(() => import('my-cool-plugin').then(r => r.default()))
// No need to load webpack plugin if using Vite
addWebpackPlugin(() => import('my-cool-plugin/webpack').then(r => r.default()))
}
})
This enables true lazy loading of build plugins, avoiding unnecessary code loading when plugins aren't needed.
This release includes several performance optimizations for faster builds:
nuxt:ssr-styles plugin is now significantly faster (#33862, #33865)rou3, removing the need for radix3 in the client bundle and eliminating app manifest fetches (#33920)The inlineStyles feature now works with webpack and rspack builders (#33966), not just Vite. This enables critical CSS inlining for better Core Web Vitals regardless of your bundler choice.
statusCode → status, statusMessage → statusTextIn preparation for Nitro v3 and H3 v2, we're moving to use Web API naming conventions (#33912). The old properties still work but are deprecated in advance of v5:
- throw createError({ statusCode: 404, statusMessage: 'Not Found' })
+ throw createError({ status: 404, statusText: 'Not Found' })
Notable fixes in this release:
key attribute (#33958, #33963)useCookie unsafe number parsing during decode (#34007)NuxtPage not re-rendering when nested NuxtLayout has layouts disabled (#34078)allowArbitraryExtensions by default in TypeScript config (#34084)noUncheckedIndexedAccess to server tsconfig for safer typing (#33985)!IMPORTANT Enabling
noUncheckedIndexedAccessin the Nitro server TypeScript config improves type safety but may surface new type errors in your server code. This change was necessary because Nuxt's app context performs type checks on server routes (learn more).While we recommend keeping this enabled for better type safety, you can disable it if needed:
export default defineNuxtConfig({ nitro: { typescript: { tsConfig: { compilerOptions: { noUncheckedIndexedAccess: false } } } } })Note that disabling this may allow type errors to slip through that could cause runtime issues with indexed access.
Alongside v4.3.0, we're releasing Nuxt v3.21.0 with many of the same improvements backported to the 3.x branch. This release includes:
setPageLayout, #server alias, draggable error overlay, and morefalseuseCookie number parsing, head component deduplication, and moreOur recommendation for upgrading is to run:
npx nuxt upgrade --dedupe
# or, if you are upgrading to v3.21
npx nuxt@latest upgrade --dedupe --channel=v3
This will deduplicate your lockfile and help ensure you pull in updates from other dependencies that Nuxt relies on, particularly in the unjs ecosystem.
!TIP Check out our upgrade guide if upgrading from an older version.
#server alias for server directory imports (#33870)crossws types (5b16a51f5)false (#33883)moduleDependencies as an async function (#33504)appLayout in route rules (#31092)setPageLayout (#33805)nuxt:ssr-styles plugin (#33862)router.replace in page hmr (#33897)page:loading:end in cache if already called (7789f73bd)NUXT_VITE_NODE_OPTIONS (41a564d23)appMiddleware references invalid key (323f27bc8)nuxt/meta (01c2c9b13)key for tag deduplication in <Head> component (#33958)build.transpile when initialising vite (#33868)onUpgrade arguments with types (#33988)rou3 (2df4e1ae3)noUncheckedIndexedAccess to server tsconfig (#33985)shared/ context (#33978)useRequestFetch (#33976)h3 types to auto-imports (#34035)nuxt/schema (a6a044d81)NuxtPage when nested NuxtLayout has explicitly disabled layouts (#34078)allowArbitraryExtensions by default (#34084)useAsyncData debounced execute post watcher flush (#34125)typeFrom support for imports.d.ts template exports (#34135)hydrate-never components (#34132)defu + consola (322dae3e0).ts file extensions to relative imports (80778c0cd)<> to as (f1713850c)~ prefix for internal ssrContext properties (#33896)status/statusText + deprecate old props (#33912)Module Author Guides (#33803)useHead return type (#33857)statusText (#32834)defineWrappedResponseHandler (#33952)addImports example (#34011)config.experimental properties (#34069)null from getCachedData trigger (f7cf3747e)useState docs (#34105).nuxtrc example (#34107)addServerHandler (#34060)appLayout (beda47955)false to its options (cdad9310c)source from <NuxtIsland> (1586bbb6e)vite-node entrypoints (#33893)obuild except for nuxt + nitro-server packages (#34049)/builder-env subpath types (7f5034288)build:stub command for those that need it (3e3d3d37a)node:process (#33982)vi.hoisted for klona mock (#34113)3.21.0 is the next minor release.
Nuxt 4.3 and 3.21 bring powerful new features for layouts, caching, and developer experience – plus significant performance improvements under the hood.
Early this month, I opened a discussion to find out how the upgrade had gone from v3 to v4. I was really pleased to hear how well it had gone for most people.
Having said that, we're committed to making sure no one gets left behind. And so we will continue to provide security updates and critical bug fix releases beyond the previously announced end-of-life date of January 31, 2026, meaning Nuxt v3 will meet its end-of-life on July 31, 2026.
!TIP As usual, today also brings a minor release for v3, with many of the same improvements backported from v4.3.
We're closer than ever to the releases of Nuxt v5 and Nitro v3. In the coming weeks, the main branch of the Nuxt repository will begin receiving initial commits for Nuxt 5. However, it's still business as usual.
main branch4.x and 3.x branchesKeep an eye out on the Upgrade Guide – we'll be adding details about how you can already start migrating your projects to prepare for Nuxt v4 with future.compatibilityVersion: 5.
But that's enough about the future. We have a lot of good things for you today!
First, you can now set layouts directly in route rules using the new appLayout property (#31092). This provides a centralized, declarative way to manage layouts across your application without scattering definePageMeta calls throughout your pages.
export default defineNuxtConfig({
routeRules: {
'/admin/**': { appLayout: 'admin' },
'/dashboard/**': { appLayout: 'dashboard' },
'/auth/**': { appLayout: 'minimal' }
}
})
This might be useful for:
!TIP Plus, you can pass props to layouts now! See the
setPageLayoutimprovements below.
Payload extraction now works with ISR (incremental static regeneration), SWR (stale-while-revalidate) and cache routeRules (#33467). Previously, only pre-rendered pages could generate _payload.json files.
This means:
export default defineNuxtConfig({
routeRules: {
'/products/**': {
isr: 3600, // Revalidate every hour
}
}
})
Related to the above, payload extraction now also works in development mode (#30784). This makes it easier to test and debug payload behavior without needing to run a production build.
!IMPORTANT Payload extraction works in dev mode with
nitro.staticset totrue, or for individual pages which haveisr,swr,prerenderorcacheroute rules.
When extending Nuxt layers, you can now disable specific modules that you don't need (#33883). Just pass false to the module's options:
export default defineNuxtConfig({
extends: ['../shared-layer'],
// disable @nuxt/image from layer
image: false,
})
Route groups (folders wrapped in parentheses like (protected)/) are now exposed in page meta (#33460). This makes it easy to check which groups a route belongs to in middleware or anywhere you have access to the route.
<script setup lang="ts">
// This page's meta will include: { groups: ['protected'] }
useRoute().meta.groups
</script>
export default defineNuxtRouteMiddleware((to) => {
if (to.meta.groups?.includes('protected') && !isAuthenticated()) {
return navigateTo('/login')
}
})
This provides a clean, convention-based approach to route-level authorization without needing to add definePageMeta to every protected page.
setPageLayoutThe setPageLayout composable now accepts a second parameter to pass props to your layout (#33805):
export default defineNuxtRouteMiddleware((to) => {
setPageLayout('admin', {
sidebar: true,
theme: 'dark'
})
})
<script setup lang="ts">
defineProps<{
sidebar?: boolean
theme?: 'light' | 'dark'
}>()
</script>
#server AliasA new #server alias provides clean imports within your server directory (#33870), similar to how #shared works:
// Before: relative path hell
import { helper } from '../../../../utils/helper'
// After: clean and predictable
import { helper } from '#server/utils/helper'
The alias includes import protection – you can't accidentally import #server code from client or shared contexts.
The development error overlay introduced in Nuxt 4.2 is now draggable and can be minimized (#33695). You can:
This is a quality-of-life improvement when you're iterating on fixes and don't want the overlay blocking your view.
https://github.com/user-attachments/assets/nuxt_4-3_error_demo.mp4
Module authors can now use async functions when adding build plugins (#33619):
export default defineNuxtModule({
async setup() {
// Lazy load only when actually needed
addVitePlugin(() => import('my-cool-plugin').then(r => r.default()))
// No need to load webpack plugin if using Vite
addWebpackPlugin(() => import('my-cool-plugin/webpack').then(r => r.default()))
}
})
This enables true lazy loading of build plugins, avoiding unnecessary code loading when plugins aren't needed.
This release includes several performance optimizations for faster builds:
nuxt:ssr-styles plugin is now significantly faster (#33862, #33865)rou3, removing the need for radix3 in the client bundle and eliminating app manifest fetches (#33920)The inlineStyles feature now works with webpack and rspack builders (#33966), not just Vite. This enables critical CSS inlining for better Core Web Vitals regardless of your bundler choice.
statusCode → status, statusMessage → statusTextIn preparation for Nitro v3 and H3 v2, we're moving to use Web API naming conventions (#33912). The old properties still work but are deprecated in advance of v5:
- throw createError({ statusCode: 404, statusMessage: 'Not Found' })
+ throw createError({ status: 404, statusText: 'Not Found' })
Notable fixes in this release:
key attribute (#33958, #33963)useCookie unsafe number parsing during decode (#34007)NuxtPage not re-rendering when nested NuxtLayout has layouts disabled (#34078)allowArbitraryExtensions by default in TypeScript config (#34084)noUncheckedIndexedAccess to server tsconfig for safer typing (#33985)!IMPORTANT Enabling
noUncheckedIndexedAccessin the Nitro server TypeScript config improves type safety but may surface new type errors in your server code. This change was necessary because Nuxt's app context performs type checks on server routes (learn more).While we recommend keeping this enabled for better type safety, you can disable it if needed:
export default defineNuxtConfig({ nitro: { typescript: { tsConfig: { compilerOptions: { noUncheckedIndexedAccess: false } } } } })Note that disabling this may allow type errors to slip through that could cause runtime issues with indexed access.
Alongside v4.3.0, we're releasing Nuxt v3.21.0 with many of the same improvements backported to the 3.x branch. This release includes:
setPageLayout, #server alias, draggable error overlay, and morefalseuseCookie number parsing, head component deduplication, and moreOur recommendation for upgrading is to run:
npx nuxt@latest upgrade --dedupe --channel=v3
This will deduplicate your lockfile and help ensure you pull in updates from other dependencies that Nuxt relies on, particularly in the unjs ecosystem.
!TIP Check out our upgrade guide if upgrading from an older version.
#server alias for server directory imports (#33870)crossws types (6ff79ea6c)false (#33883)moduleDependencies as an async function (#33504)appLayout in route rules (#31092)setPageLayout (#33805)nuxt:ssr-styles plugin (#33862)router.replace in page hmr (#33897)page:loading:end in cache if already called (fbbe10133)NUXT_VITE_NODE_OPTIONS (8abb7ef5b)appMiddleware references invalid key (ed8bb68c5)nuxt/meta (b748840bc)key for tag deduplication in <Head> component (#33958)build.transpile when initialising vite (#33868)onUpgrade arguments with types (#33988)rou3 (7da94e8c3)noUncheckedIndexedAccess to server tsconfig (#33985)useRequestFetch (#33976)h3 types to auto-imports (#34035)nuxt/schema (9b40196a6)NuxtPage when nested NuxtLayout has explicitly disabled layouts (#34078)allowArbitraryExtensions by default (#34084)useAsyncData debounced execute post watcher flush (#34125)typeFrom support for imports.d.ts template exports (#34135)hydrate-never components (#34132)defu + consola (e31668f67).ts file extensions to relative imports (458f3c9b6)<> to as (08f72881e)~ prefix for internal ssrContext properties (#33896)status/statusText + deprecate old props (#33912)nitropack/runtime namespace (b06d53166)nitropack/runtime namespace (897a2259f)useHead return type (#33857)Module Author Guides (#33803)statusText (#32834)defineWrappedResponseHandler (#33952)useState docs (#34105).nuxtrc example (#34107)appLayout (9b78698c3)false to its options (18500730c)source from <NuxtIsland> (08778c98c)vite-node entrypoints (#33893)obuild except for nuxt + nitro-server packages (#34049)/builder-env subpath types (1951648fa)build:stub command for those that need it (c682b2681)node:process (#33982).nuxtrc with test-utils setup (b5879351f)vite-node separately from vitest (8114e886f)vi.hoisted for klona mock (#34113)weekNumbers prop (#4555) (7a1a71b)indicator prop (#5257) (6a925cd)estimateSize as function (#5748) (d51b424)input prop (#5736) (12052e8)size prop (#5878) (3ae04c6)by prop (#5906) (36cd5e5)valueKey prop (#5905) (55646ea)placeholder.mode prop (d90acb3), closes #5785size prop in menus (#5889) (571d50d)taskList handler (#5837) (db04197)image and mention props (b6fa83a), closes #5820ignoreFilter prop (#5880) (f8d1883)viewportRef for infinite scroll (#5836) (f4a945c)clear prop (#5643) (ec6b8ec)align prop (859390e), closes #5795select event (#5826) (8e431be)contentType when updating value (c37d6f7), closes #5709onClick from being called twice on items (cbed0cc), closes #5784main instead of div (6ccb1f5)cs and sk terminology for correct inflection (#5789) (af6f288)primary color and md size default variants (f422de8)expandAll prop (c79cb77), closes #5828Full Changelog: https://github.com/nuxt/ui/compare/v4.3.0...v4.4.0
No significant changes
rewriteLLMSTxt option to disable rewriting paths in llms.txt - by @farnabaz (38e57)mdc.components.map to renderer aliases - by @farnabaz (7eebe)3.23.0 is the next minor release.
$fetch is not typed as any (1f4754ea9)console.log (aef693340)3.22.0 is the next minor release.
vitest in separate process (#1524)NuxtPage exists (#1530).sync method for syncing route (1148c3cf1)server.deps rather than deps (2b3c86921)sync() in initial setup (ec555192c)devtools:before hook instead of direct config check (#1532)rootDir (#1531)addCleanup (86b4998bb)nuxt cli command in preference to nuxi (838ed8b6a)@vitest/ui to example (ffaccd8a1)package.json names (417102718)defaultLocale in i18n test (059988fc3)knip on pull requests (a94098671)