Welcome to HowToShipIt — practical how-to guides for developers: code, AI tools, and servers, explained step by step.

How to Upgrade Nuxt 3 to 4 Without Breaking Your App (2026)

If you still run Nuxt 3 in production, you are running unmaintained software. Nuxt 3 reached end of life on 31 July 2026, and this guide shows you how to upgrade Nuxt 3 to 4 without the big-bang rewrite that breaks things in ways the error messages never explain. The trick is not a faster upgrade. It is a staged one: surface every breaking change while you are still on Nuxt 3, fix them one at a time, and only then bump the package.

That matters because the upgrade is not one change. It is a new directory layout, a reworked data layer, new TypeScript contexts, and a module ecosystem that moved at different speeds. This post was written on 25 October 2026 against Nuxt 4.6.2, the current 4.x release.

Why the upgrade cannot wait

Nuxt 3 reached end of life on 31 July 2026. The framework’s own roadmap states it plainly: Nuxt 3 no longer receives bug fixes or security patches. Your app will keep running — packages stay on npm — but the next vulnerability in the 3.x line will not be fixed for you. The 3.x line’s last listed release is 3.21.11, and endoflife.date records maintenance support ending on 31 July 2026.

Nuxt 4, by contrast, is the stable line: it shipped on 16 July 2025 and the current release is 4.6.2 (16 October 2026). Waiting for Nuxt 5 is not a plan either — Nuxt 5 is in development with no committed release date, and every month you wait is another month on an unpatched framework. The honest exception is a team that buys extended support deliberately; for everyone else, the upgrade is the security patch.

There is also good news, and it is the whole premise of this guide: the Nuxt team designed the 3-to-4 move to be gradual. Since Nuxt 3.12 you can opt into Nuxt 4 behaviour while still running the Nuxt 3 package, and the official migration codemod automates the mechanical renames. Most projects, the team reports, upgrade with a minimum of effort. The effort goes into the handful of silent breakages below — the ones that do not throw errors.

Upgrade Nuxt 3 to 4: the staged path

Do not start with npm install nuxt@latest. Start with a branch, a backup, and a baseline you can compare against.

Stage 0: baseline before you touch anything

Create a branch, commit a clean tree, and record three baselines: npm run build passing, your test suite passing, and a quick smoke pass over your highest-traffic pages (including one SSR page and one page that fetches data). If you cannot reproduce a failure later, you cannot tell whether the upgrade caused it. While you are here, check your Node version: the Nuxt 4.6 CLI requires Node 22.21+, 24.11+ or 26+, and nuxt init has been dropped in favour of npm create nuxt@latest for new projects. Bump Node before you touch Nuxt, not during.

Then audit your modules. This is the step most guides skip and the one that blocks most real upgrades: a single community module without Nuxt 4 support will hold the whole project hostage. For each module in your nuxt.config.ts and modules/ directory, check its changelog for Nuxt 4 support and note the compatible version. First-party @nuxt/* modules are current; community modules vary. If a module has no Nuxt 4 release, decide now — replace it, drop it, or pin your upgrade until it lands — rather than discovering it mid-migration.

Stage 1: opt into Nuxt 4 behaviour while still on Nuxt 3

This is the single most valuable step, and it is the one the “upgrade in 10 minutes” guides gloss over. While your package.json still says "nuxt": "^3.x", add this to nuxt.config.ts:

export default defineNuxtConfig({
  future: {
    compatibilityVersion: 4,
  },
})

With that flag set, your Nuxt 3 app runs with Nuxt 4’s new defaults — the data layer contract, the directory resolution, the changed defaults — so you see every real breakage in your own code, on your own dev server, without touching your dependency tree yet. Fix what it surfaces, commit, and repeat until the flag produces a clean dev server and a clean build. Only then is the package bump a small step instead of a leap.

One related habit pays off here: bump your compatibilityDate too. An old pinned date can keep you on legacy Nitro behaviour even after the package upgrade, which produces exactly the class of “but I upgraded” bug that wastes an afternoon.

Stage 2: run the official codemod

Once the flag is clean, run the migration recipe. The official guide pins the version deliberately, because @latest has a known issue with this recipe:

npx codemod@0.18.7 nuxt/4/migration-recipe

The recipe runs the codemods in sequence and lets you deselect any you do not want. It handles the mechanical work — moving files into the new app/ layout and applying known fixes for breaking changes. Review its diff by hand afterwards. Codemods move files; they do not understand your custom paths, your Tailwind or ESLint configs, or the watcher patterns your tooling relies on. Verify those yourself.

Stage 3: bump the package, then verify in layers

Now bump Nuxt itself:

npm install nuxt@^4.0.0

Then verify in layers, smallest blast radius first: npm run dev and click through the smoke pages; npm run build; your test suite; and finally a production-like check of SSR and hydration on the pages that matter most. If something breaks at this stage, you know it is the package bump or a module — not your code, because your code already passed under the compatibility flag. That narrowing is the entire point of staging.

The 5 breakages that actually bite

1. The app/ directory — and the ~ alias that moves with it

Nuxt 4’s biggest visible change is the new default layout: your application code (pages/, components/, composables/, layouts/, middleware/, plugins/, app.vue, error.vue, app.config.ts) now lives under app/ by default, because the new default srcDir is app/. The folders that stay at the root are server/, public/, modules/ and content/ — move those into app/ and you will break your server routes and static assets in one move.

The subtle part is the ~ alias: it now points to the app/ directory, so ~/components resolves to app/components/. Any hardcoded path, custom srcDir, or tooling config that assumed the old root layout needs checking — Tailwind content globs, ESLint overrides, and CI scripts that reference paths are the usual suspects. And note the escape hatch the official guide states plainly: migration is not required. If Nuxt detects your old structure it keeps working, and if you have a custom srcDir you should know your modules/, public/, shared/ and server/ folders are now resolved from rootDir rather than your custom srcDir. You can also force the old structure with srcDir: '.', but treat that as a delaying tactic, not a destination.

2. Shared fetch keys now share one data object

Nuxt 4 reorganised useAsyncData and useFetch into a deduplicated data layer. All calls with the same key now share the same data, error and status refs — which is a performance win and a correctness trap at the same time. Two components using the same key with conflicting options (deep, transform, pick, getCachedData or default) now trigger a warning, and the official guide’s advice is to extract shared-key calls into their own composable so there is exactly one owner of the options.

// app/composables/useUserData.ts
export function useUserData(userId: string) {
  return useAsyncData(
    `user-${userId}`,
    () => fetchUser(userId),
    { deep: true },
  )
}

There is a second, quieter trap inside the same change: if you fetch page-specific data with useAsyncData and no key, or with a key that does not reflect the route, prerendered pages can share payload data that was never meant to be shared. The official guide’s example is a [slug].vue page fetching /api/my-page/${route.params.slug} under a generic key — the key must uniquely identify the data fetched, or one page’s data will leak into another’s prerendered output. Audit every keyless useAsyncData call in a dynamic route before you ship.

3. Shallow reactivity: deep mutations stop updating the UI

In Nuxt 4, fetched data is shallow-reactive by default. Code that mutates a nested property of fetched data in place — data.value.user.name = 'New' — will change the object without the UI noticing, which looks exactly like an unrelated rendering bug. That is the single most common silent breakage in the migration, and it produces no error, no warning, and no failed build.

The fix is to decide per call: where you genuinely need deep reactivity, pass deep: true; everywhere else, replace the object instead of mutating it (data.value = { ...data.value, user: updatedUser }). During Stage 1, grep for in-place mutations of fetched data and treat each one as a migration item, not a style nit. If a page “randomly” stops updating after the upgrade, this is the first place to look.

4. The null-to-undefined default, and other small contract changes

Nuxt 4 changed the default value of unfetched data from null to undefined. Any guard written as if (data.value === null) will silently pass a stale check — the loading state you thought you handled no longer triggers. Search for === null checks on fetched data during Stage 1 and convert them to falsy checks or explicit undefined handling.

The same “small contract change” family includes two more worth a grep: route.meta.name no longer mirrors route.name — page metadata like name and path is now only on the route object itself, so read route.name instead; and component names now match the Nuxt auto-import pattern, so any <KeepAlive> include list or findComponent call in tests that relied on the old filename-based name needs updating. None of these breaks a build. All of them break behaviour.

5. Modules and layers load in the corrected order

Nuxt 4 corrected the module loading order for layers: layer modules now load first (deeper layers first), and project modules load last with the highest priority. Previously it was reversed. Most projects will not need changes — the new order matches the intuitive inheritance pattern — but if your project worked around the old incorrect order, for example by configuring a module to compensate for running too early, that workaround is now the bug. Review any module that depends on load order, and if a module needs to run after everything else, the modules:done hook exists for exactly that.

Two related cleanups belong in the same pass. Unhead moved to v2, which removed the vmid, hid, children and body props from head tags and no longer supports promise input — strip those props from useHead calls. And Nuxt now inlines only component styles, not global CSS, which is the better default (one cacheable global file instead of a bloated first document) but will change your first-paint numbers; measure before and after rather than assuming a regression.

Your pre-flight checklist

Run this list in order, and do not skip the last three items — they are the ones that catch the silent breakages:

  • Branch, commit, and record build, test, and smoke-test baselines.
  • Bump Node to a version the Nuxt 4.6 CLI supports (22.21+, 24.11+ or 26+).
  • Audit every module for Nuxt 4 support; replace or drop the ones without it.
  • Set future.compatibilityVersion: 4 on Nuxt 3 and fix everything it surfaces.
  • Bump compatibilityDate so you are not silently on legacy Nitro behaviour.
  • Run npx codemod@0.18.7 nuxt/4/migration-recipe and review the diff by hand.
  • Grep for shared fetch keys with conflicting options, keyless useAsyncData in dynamic routes, in-place mutations of fetched data, === null data checks, route.meta.name, and vmid/hid props.
  • Verify in layers: dev server, production build, test suite, SSR and hydration smoke tests.
  • Ship behind your normal deploy pipeline with a rollback plan (see below), not a Friday-afternoon direct push.

Rollback: plan it before you need it

A staged upgrade is easy to roll back precisely because each stage is a commit. Keep the compatibility-flag commit, the codemod commit, and the package-bump commit separate, so a failure in production means reverting one commit, not untangling three. Before the production deploy, confirm two things: your previous build artifact is still deployable (do not let the deploy pipeline garbage-collect it mid-migration), and your data-layer changes are backwards compatible with the old build if a revert happens mid-request. If either answer is no, fix that before you ship, not after.

If the upgrade stalls on a module with no Nuxt 4 release, that is a decision point, not a failure: replace the module, drop the feature it powered, or stay on the compatibility flag on Nuxt 3 for a defined window while you do the replacement work. What you should not do is stay on Nuxt 3 indefinitely without a plan — the end-of-life date has already passed, and every week on 3.x is a week without security patches.

Should you skip Nuxt 4 and wait for Nuxt 5?

Only with a security plan for the gap. Nuxt 5 is in development and, from Nuxt 4.2+, you can already test many of its breaking changes with future.compatibilityVersion: 5 — case-sensitive routing, serializable page meta, and the rest. But testing Nuxt 5 defaults is not the same as running a supported framework, and Nuxt 3’s support has already ended. The sane path is Nuxt 4 now, with the Nuxt 5 compatibility flag as a later, separate staged migration using exactly the technique in this post. The staged path works twice.

Further Reading & References

Internal reading on this blog: Nuxt 3 SEO: The Complete Guide and Vue Vapor Mode Explained — the first covers the Nuxt 3 setup you are migrating from, the second covers the Vue 3.6 direction your upgraded app will build on.

Leave a Comment