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

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

If your production app still runs on Nuxt 3, the clock has already run out. Nuxt 3 reached end of life on 31 July 2026, and the official roadmap is blunt about what that means: it “no longer receives bug fixes or security patches”. The 3.x line is frozen at 3.21.11, a patch that shipped on 5 August 2026. Your app will keep running — npm packages do not disappear — but the next vulnerability disclosed against Nuxt 3, Nitro, or h3 will not get a 3.x fix. This Nuxt 4 upgrade guide walks you through the move, in the order that causes the least pain, using the staged path the Nuxt team itself recommends.

The good news first: this is not Nuxt 2 to Nuxt 3. That migration was a rewrite. Nuxt 3 to Nuxt 4 is a version bump, a folder reshuffle, and a handful of changed defaults — mostly in data fetching and TypeScript. Nuxt 4.0 shipped on 15 July 2025, and the current release is 4.6.4 (2 November 2026), so you are upgrading onto a line with more than a year of patch releases behind it.

Before you touch anything: the 10-minute audit

Do this on a branch, on your current Nuxt 3 install, before any upgrade command runs. Every failure you find after this point should belong to the upgrade — not to a test suite that was already red.

  1. Check Node. Nuxt 4 requires Node ^20.19.0 || >=22.12.0. If node --version prints anything outside that range, upgrade Node first — in development, in CI, and on your production host. Node 18, which Nuxt 3.17 still accepted, is out.
  2. Get a green test suite. Run your unit tests and npx nuxi typecheck on Nuxt 3 and fix what fails. You need a baseline.
  3. List your modules. Run npx nuxi info. It prints your Nuxt version and every module in nuxt.config.ts. For each one, open its changelog or releases page and look for a version that states Nuxt 4 support. Nuxt 2 and Bridge support has been removed from @nuxt/kit, so a module that was never updated for Nuxt 4 can break regardless of anything else you do. As one concrete example, Nuxt UI v4 requires Nuxt 4.1 or later — check your UI layer the same way.
  4. Note your custom config. Search your codebase for generate. config, window.__NUXT__, === null checks near useFetch/useAsyncData, and vmid/hid in head tags. Each of these is a known breakage point, covered below.

Stage 0: flip the compatibility flag while still on Nuxt 3

The single best decision in this whole migration is to fix the breaking changes before you bump the package. Most of what Nuxt 4 changes has been available behind a flag in Nuxt 3 since version 3.12. Add one line to nuxt.config.ts:

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

Run your test suite and your app with the flag on. Everything it surfaces is a real Nuxt 4 breakage, found while you are still on the supported-by-you version of the code, with the smallest possible blast radius. Fix each one, commit, and only then move to the package bump. Teams that skip this stage end up debugging the flag changes and the package changes at the same time.

Stage 1: the two commands that do most of the work

With the flag green, upgrade the package:

npx nuxt upgrade --dedupe

The --dedupe flag matters: it refreshes the packages Nuxt depends on and deduplicates the lockfile, so you do not end up with two copies of an internal package. Then run the official migration recipe, which runs the codemods in sequence and lets you deselect any of them:

npx codemod@0.18.7 nuxt/4/migration-recipe

Use the pinned 0.18.7 version — the official upgrade guide pins it because of a known issue with the latest codemod release. The recipe automates the mechanical parts: moving files into app/, rewriting null checks on fetched data, adding { deep: true } where you relied on deep reactivity, and more. It does not cover every step, so treat its output as a starting point and review the diff like any other pull request.

The 7 breaking changes that actually bite

Nuxt 4’s upgrade guide lists dozens of changes, but most are minimal-impact. These seven are the ones that break real apps — usually silently, which is worse.

1. The app/ directory (and the ~ alias moves with it)

Nuxt 4’s headline change: application code — components/, pages/, layouts/, app.vue, error.vue, app.config.ts — now lives under app/ by default, while server/, shared/, public/, layers/, and modules/ stay at the project root. There is also a new shared/ directory for code used by both the Vue app and the Nitro server, with auto-imports for shared/utils/ and shared/types/.

The move is opt-in in practice: if Nuxt detects your old layout (a top-level pages/ directory), it keeps it and your app still loads. But the ~ alias now points at app/ by default, so ~/components resolves to app/components/ — update any import or config that assumed the old root. The codemod npx codemod@latest nuxt/4/file-structure moves the folders for you, or do it by hand with git mv so the history survives. Remember to update third-party config that scans your folders, such as Tailwind or ESLint config. The payoff is real: keeping all your code out of the repo root stops filesystem watchers scanning .git/ and node_modules/, which noticeably speeds up startup on non-Mac systems.

2. data and error are undefined now, not null

This is the silent one. In Nuxt 3, data and error from useAsyncData and useFetch were initialised to null. In Nuxt 4 they default to undefined. Any guard written as if (data.value === null) now passes straight through on an unfetched request, and your template renders a loading state as if data had arrived — or worse, renders nothing and you only find out from a user report.

// Before (Nuxt 3)
if (data.value === null) { /* still loading */ }

// After (Nuxt 4)
if (data.value === undefined) { /* still loading */ }

Grep for === null and !== null near every useAsyncData and useFetch call before you upgrade, not after a bug report finds one. The codemod npx codemod@latest nuxt/4/default-data-error-value rewrites these checks automatically.

3. Fetched data is a shallowRef

The data object returned from useAsyncData, useFetch, and their lazy variants is now a shallowRef instead of a ref. Replacing the whole object still triggers reactivity, but mutating a property inside the fetched data no longer does. This is a deliberate performance win — Vue no longer watches every nested property of potentially large payloads — but code that does data.value.items.push(newItem) and expects the UI to update will silently stop working.

The fix is per-call, where you actually need it:

- const { data } = useFetch('/api/test')
+ const { data } = useFetch('/api/test', { deep: true })

Do not flip the project-wide default back on unless you have measured a real problem — the codemod npx codemod@latest nuxt/4/shallow-function-reactivity adds { deep: true } to every call, which keeps Nuxt 3 behaviour everywhere but throws away the performance gain. Better: let the codemod find the calls, then remove the flag from the ones that never mutate nested data.

4. Same key now means the same fetch — the singleton data layer

Nuxt 4 makes a hard contract out of something that was previously loose: all calls to useAsyncData or useFetch with the same key now share the same data, error, and status refs. Calls sharing a key must agree on handler, deep, transform, pick, getCachedData, serialize, default, and middleware — conflicting options now trigger a warning. Two other behaviours changed with it: data is cleaned up when the last component using it unmounts (no more ever-growing memory usage), and keys can be reactive refs or getter functions, so data refetches automatically when the key changes.

Two practical consequences. First, extract shared-key fetches into a composable instead of duplicating the call with different options in two components. Second, getCachedData is now called on every fetch — including watcher-triggered refreshes — and receives a context object telling you why: ctx.cause is one of 'initial' | 'refresh:hook' | 'refresh:manual' | 'watch'. If your cache function assumed it only ran on first load, update it:

useAsyncData('key', fetchFunction, {
  getCachedData: (key, nuxtApp, ctx) => {
    // Don't serve stale cache on a manual refresh
    if (ctx.cause === 'refresh:manual') return undefined
    return cachedData[key]
  },
})

Also note the related change: with immediate: false, a key change only refetches if the data has already been fetched once. If you relied on the old behaviour where useFetch always fetched on key change, you now need to call execute() manually the first time.

5. window.__NUXT__ is gone after hydration

Nuxt removes the global window.__NUXT__ object once the app finishes hydration, to open the way for multi-app patterns and to leave one way of accessing Nuxt app data: useNuxtApp(). If any of your code — or a third-party script — reads the payload from the window object, it breaks:

- console.log(window.__NUXT__)
+ console.log(useNuxtApp().payload)

Search your codebase and any vendored scripts for __NUXT__ before deploying. This one fails at runtime, not at build time, so your test suite may not catch it.

6. pending is now a computed value

The pending flag from useAsyncData and useFetch is now a computed property that is true only when status is also pending. Previously, with immediate: false, pending was true until the first request was made. Now it is false until that first request starts, which means a template guarded by v-if="!pending" will render the “loaded” branch before anything has loaded. The fix the guide recommends is to check status directly:

<div v-if="status === 'success'">
  <p>Data: {{ data }}</p>
</div>
<div v-else>
  <p>Loading...</p>
</div>

7. Unhead 2 and the removal of generate.*

Two smaller removals that still bite. First, Unhead — the library that generates your <head> tags — has been updated to version 2, which removes the vmid, hid, children, and body props from head tags, and no longer accepts Promise input. If your SEO setup used vmid or hid to deduplicate meta tags, delete those props; tags are now sorted with Capo.js by default. If you still have issues, unhead: { legacy: true } in your config restores the v1 behaviour while you migrate.

Second, the top-level generate configuration option is gone entirely — generate.routes and generate.exclude included. It was a Nuxt 2 holdover; use nitro.prerender instead:

export default defineNuxtConfig({
  nitro: {
    prerender: {
      ignore: ['/admin', '/private'],
      routes: ['/sitemap.xml', '/robots.xml'],
    },
  },
})

While you are in the config, check the TypeScript changes too: Nuxt now generates separate TypeScript configurations for app, server, shared, and build-time code (.nuxt/tsconfig.app.json, .nuxt/tsconfig.server.json, and so on), and compilerOptions.noUncheckedIndexedAccess is now true. Run a full typecheck after the upgrade and fix the new errors it surfaces — that is the feature working, not a regression.

Modules: audit before you deploy

The upgrade command updates Nuxt itself. It does not update your modules, and that is where most failed upgrades actually happen. Work through the list from npx nuxi info and, for each module:

  • Check its changelog for a Nuxt 4 release. If there is none, stay on Nuxt 3 for that app and open an issue with the module — or drop the module if it is unmaintained.
  • Watch for modules that relied on the old module loading order. Nuxt 4 corrected it: layer modules now load first (deeper layers first), project modules last. If a module was configured to work around the old, reversed order, that workaround is now the bug.
  • Update @nuxt/test-utils to 3.19.2 or later, which requires Vitest 3.2 — your component tests will fail on the old version.
  • If you use layers, remember the layer also needs the compatibilityVersion: 4 flag during the staged migration, and its modules need the same audit.

What you get for the trouble

The upgrade is not just maintenance. Nuxt 4.4 moved to Vue Router v5, the first major router upgrade since Nuxt 3. Version 4.6 added nuxt/server imports, so server handlers can be written to run on both Nitro v2 and the Nitro v3 that Nuxt 5 will ship with. And if you are already thinking past this migration, Nuxt 5 is in development: from Nuxt 4.2 onwards you can preview many of its breaking changes with future.compatibilityVersion: 5 — the same staged trick, one major ahead. Nuxt’s support policy commits to supporting each major version for a minimum of six months after the next major ships, so moving to Nuxt 4 now buys you a supported line well past Nuxt 5’s release.

Verify before you ship

Run this checklist on your branch before merging:

  1. npx nuxi typecheck — clean, with the new split TypeScript configs.
  2. Full test suite — green, on the new Node version, in CI.
  3. npm run build and npm run preview — then click through every page that uses useFetch with a shared key, a pending guard, or a === null data check.
  4. Check the prerendered output: sitemap, robots, and any routes you previously listed under generate.routes.
  5. Deploy to staging first and watch the server logs for the warnings Nuxt 4 emits about conflicting useAsyncData options — they point directly at the components you missed.

5 mistakes to avoid

  • Upgrading the package and flipping the flag in the same commit. Do the flag first, on Nuxt 3. Two changes at once means two suspects for every failure.
  • Skipping the module audit. The framework upgrade is the easy part. An unmaintained module is the part that takes your app down on a Friday.
  • Trusting === null checks. They now pass on unfetched data. Grep first, deploy second.
  • Moving files into app/ as the first step. It is cosmetic until the behaviour changes are fixed, and it creates a huge diff that hides real breakage. Fix behaviour, then move folders — or let the codemod do it last.
  • Staying on Nuxt 3 and hoping for another extension. The EOL date was already extended once, from 31 January to 31 July 2026, after community feedback. No further extension has been announced. If you genuinely cannot migrate yet, Nuxt’s official end-of-life partner HeroDevs sells extended support for the 3.x line — but that is a bridge with a price tag, not a plan.

Nuxt 3 served for almost four years, from November 2022 to July 2026. The upgrade to Nuxt 4 is the smallest major-version move the framework has ever shipped — a flag, two commands, and seven changes to check by hand. Do it on a branch this week, while the migration is a planned afternoon of work and not an incident response to a vulnerability with no patch.

Further Reading & References

Leave a Comment