10 min read

Nuxt 4.7: The Test Drive

Nuxt 4.7 lets you opt into Nitro v3 before Nuxt 5, adds experimental WebMCP, a unified problems drawer, server-side error boundaries, validated runtime config, and a serious performance pass. A personal note on the release that finally lets us drive the future instead of waiting for it.

Vantol Bennett

Vantol Bennett

Educator / Developer

Contents (11)

Last time I wrote about Nuxt, I called 4.6 the runway to Nuxt 5. I meant it as a compliment: a release that pre-paid the migration instead of rushing the major. Nuxt 4.7 is the first time we get to taxi down that runway.

Around 350 commits since v4.6.4. The headline is not a new UI feature or a compiler trick. It is this: you can build your Nuxt 4 app with Nitro v3 today, the same server engine Nuxt 5 is built on. No config rewrite. Add one dependency. See what happens.

That is a different kind of release. It is a test drive.

Full disclosure: this site is on 4.7 now. It runs staticRoutes, webmcp, and ssrErrorBoundary, and its public config is declared with Zod. The build passed before I wrote a word.

Main Content

The main event: Nitro v3 under Nuxt#

Nitro v3 is a ground-up rewrite of the server: h3 v2, web-standard Request/Response, srvx, a compiled router, a much smaller install, runtime mode, Vitest support, and the same deploy-anywhere promise. It is also the foundation of Nuxt 5. Until 4.7, testing it meant leaving Nuxt.

Now it is one line:

terminal
pnpm add nitro

If nitro is in your package.json, Nuxt builds with Nitro v3. Remove it, and you are back on Nitro v2. That is the whole switch.

I went the other way: I built a standalone Nitro v3 app first, then came back to Nuxt. The first thing I noticed was not a crash. It was the speed. On Nuxt's benchmark app with about 170 pages, the same app served 33% more requests per second on the home page with Nitro v3 (926 → 1,236), and 44% more on a page with 1,000 links (219 → 316), with identical HTML. That is not a micro-benchmark. That is the server engine doing less work per request.

Nitro v3 is still a release candidate. It is highly experimental in Nuxt 4.7. Try it on a branch, not in production. The point is to find the code that still depends on Nitro v2 before Nuxt 5 finds it for you.

The compatibility layer is the teacher#

Most Nuxt 4 apps and modules were written for Nitro v2 and h3 v1. So Nuxt 4.7 runs Nitro v3 with a compatibility layer called nitroLegacy, on by default. It keeps imports from h3, nitropack, and #imports resolving; keeps the Nitro v2 auto-imports; keeps useRuntimeConfig(event), event.node, and the old hooks working; and keeps a long list of h3 v1 behaviours, from sendRedirect ending the response to the cache-control headers cached routes send.

That layer is not a permanent home. It is a diagnostic tool. Turn it off:

nuxt.config.ts
export default defineNuxtConfig({
  nitroLegacy: false,
});

Then the errors tell you exactly which files still expect the old world. In my case, most of them were imports I had stopped thinking about years ago.

Two changes happen regardless of the layer:

  1. Route rule patterns. Nitro v3 matches with rou3. A single * now matches any number of segments, so /blog/* also applies to /blog/2026/hello. Nuxt warns about every rule whose meaning changes and stops on a rule with more than one wildcard. Use a named parameter (/blog/:slug) when you mean one segment.
  2. Imports your server code never declared. Nitro v2 quietly fell back to Nuxt's own dependency tree. Nitro v3 does not. If your server imports ufo but your app does not depend on it, nuxt dev fails with Cannot find package 'ufo'. That is a good failure. It makes the dependency real.

There is a longer list in the upgrade guide, and it is worth reading before you flip the switch. The short version: try it, turn off the layer, fix what it finds, and you have done most of the Nuxt 5 server migration on 4.7.

That standalone app is Ampyard: a fictional EV charging depot with no Nuxt in the room. Nine stages, real D1, cron, SSE, WebSockets, and a charger-agent OpenAPI contract. If you want the engine without the framework conventions, start here: Nitro v3 in Practice: Build Ampyard. It is the companion piece to this post.


WebMCP: the fun one#

The second headline is WebMCP, an experimental browser API that lets a page offer tools to AI agents running in the browser. It started from Sarah Drasner's proposal for Vue and WebMCP, and Nuxt 4.7 ships an implementation.

Turn it on:

nuxt.config.ts
export default defineNuxtConfig({
  experimental: {
    webmcp: true,
  },
});

Most of what an agent needs is already bound in your template. Tag a function with @tool:

app/pages/index.vue
<script setup lang="ts">
const { data: products } = await useFetch('/api/products')
const cart = useCart()

/**
 * Add one of a product to the cart. Use when the user wants to buy something.
 * @tool
 */
function addToCart (sku: string) {
  cart.value.push(sku)
}
</script>

<template>
  <ul>
    <li v-for="product in products" :key="product.sku">
      {{ product.name }}
      <button :disabled="!product.inStock" @click="addToCart(product.sku)">
        Add
      </button>
    </li>
  </ul>
</template>

That registers an add_to_cart tool. The arguments come from the template, so an agent can only do what a user could click, and it cannot run while the button is disabled. Inside a v-for, the :key becomes a target the agent picks, and a shared list_targets tool lists what is on screen.

On this site, the article page registers a copy_article_link tool with defineAgentTool() and useAgentTool(), and the Save button carries the template @tool tag.

A @tool bound to @submit becomes a form tool. Its input is the form's v-model bindings, and a call fills in the form and submits it for real, so your validation and submit handler run exactly as they would for a person.

For tools that do not map to a single control, there is defineAgentTool() and useAgentTool():

app/pages/products.vue
const searchProducts = defineAgentTool({
  name: 'search_products',
  description: 'Find products by name. Use when the user asks what is for sale.',
  input: z.object({ query: z.string() }),
  annotations: { readOnlyHint: true },
  execute: ({ query }, { signal }) => $fetch('/api/products', {
    query: { q: query },
    signal,
  }),
})

useAgentTool(searchProducts)

And useAgentActivity() lets you show the user what the agent is doing, and stop it:

app/components/AgentStatus.vue
<script setup lang="ts">
const { current, stop } = useAgentActivity()
</script>

<template>
  <p v-if="current">
    {{ current.message }} <button @click="stop">Stop</button>
  </p>
</template>

Nuxt also registers a navigate tool listing your pages, warns at build time about bindings that cannot become tools, and in development writes the tools of each page you visit to .nuxt/webmcp/schema.json, ready for webmcp-evals.

The WebMCP spec is still moving, and the API is in early preview in Chrome behind a flag. In browsers without it, nothing registers and your app behaves exactly as before. That is the right failure mode for an experiment.

Why I like this one: it is the first AI feature in a framework release that feels native to the web instead of bolted on. The tools are the UI. The agent cannot hallucinate a button that does not exist. It can only click what you already shipped.


One drawer for all your problems#

Nuxt 4.6 brought my-bad error pages to development. In 4.7, with my-bad v1 and vite-plugin-checker v1, the same badge in the corner also collects problems:

  • type errors, when typescript.typeCheck is on;
  • any checker you add to Vite, such as ESLint;
  • Vue compiler warnings that used to be lost in the terminal;
  • Nuxt's own warnings from scanning your app, such as duplicate component names or conflicting imports.

Each source becomes a problem set. The badge sums them into one pill. Click it and you get a drawer beside the page, grouped by source, with source snippets, links to the rule docs, and a button to open each one in your editor.

This is the feature I did not know I wanted. I used to keep three terminals open: dev server, vue-tsc --watch, ESLint. Now the page tells me. The DevTools v4 Problems panel shows the same list if you prefer the dock.

You can also choose when type checking runs:

nuxt.config.ts
export default defineNuxtConfig({
  typescript: {
    typeCheck: 'dev', // `true`, 'build' or 'dev'
  },
});

If you already run nuxt typecheck in CI, 'dev' is the right default. You get the feedback while you work, and the production build stays fast.

Template diagnostics: the compiler knows your app#

The Vue compiler cannot know about your pages or your server components. Nuxt can. So 4.7 checks templates for mistakes that only make sense with that knowledge:

  • a <NuxtLink> whose static to does not match any page (NUXT_B4025);
  • v-on or v-model on a server component, which cannot work (NUXT_B3014);
  • a function or class instance passed as a prop to a server component (NUXT_B3015).

In development these show up on every open page as a problem set until you fix them. They are on by default. Turn them off with experimental.templateDiagnostics: false if you need quiet, but I would leave them on. A dead link in a template is exactly the kind of thing that survives to production because no one clicks it in review.


Error boundaries that hold on the server#

<NuxtErrorBoundary> used to catch errors on the client only. A component that threw while server rendering went straight past it to your error page. With experimental.ssrErrorBoundary, it catches on the server too:

app/pages/index.vue
<template>
  <NuxtErrorBoundary>
    <BrokenWidget />
    <template #error="{ error, clearBoundaryError }">
      <p>Widget unavailable</p>
      <button @click="clearBoundaryError">Retry</button>
    </template>
  </NuxtErrorBoundary>
</template>

If <BrokenWidget> throws on the server, the response is a 200 with the rest of the page intact and the #error slot in its place. The client hydrates into the same state. In production, errors that are not HTTP errors reach the slot as a plain 500, so server error messages stay out of your HTML.

There is also a new retry-on-client prop: serve the #error slot in the HTML, then try the real content again in the browser. That is the replacement for <NuxtClientFallback>, which is now deprecated.

On this site, the reader stats row (views, reactions, presence) is wrapped in a boundary. If presence is down, the essay still renders.

One small but important rename: the slot exposes clearBoundaryError instead of clearError. If you forgot to destructure the old name, your template called the global clearError and the boundary stayed broken. The new name cannot collide. Good API design is often a rename that removes a footgun.


Runtime config that fails at boot, not in production#

Runtime config values have always been typed from their defaults, and environment variables were cast with destr. That meant you could not really declare a required value, or an enum, and occasionally a number-looking string such as 4848e0 turned into a number.

Now any value in runtimeConfig can be a Standard Schema, such as Zod, ArkType, or Valibot:

nuxt.config.ts
import { z } from 'zod'

export default defineNuxtConfig({
  runtimeConfig: {
    apiSecret: z.string(), // required, so it must be set at runtime
    session: z.object({
      maxAge: z.number().int().default(60 * 60),
      secure: z.boolean().default(true),
    }),
    public: {
      mode: z.enum(['preview', 'production']).default('production'),
    },
  },
})

The schema sets the type, and its default is the default value. Environment variables are converted to that type when the server starts. If a value is missing or cannot be converted, the server does not start, and you get one error listing everything that is wrong.

The best part: the schema never ends up in your server bundle. Nuxt compiles it at build time into a tiny description (types, required values, enums, unions). Modules can declare schemas too with updateRuntimeConfig().

This is boring infrastructure in the best way. A missing secret should stop a deploy, not surface as undefined in a Stripe call three hours later. This site now declares its public config with the same schema.


Performance: the free kind#

I have written about framework performance before, and I am suspicious of benchmarks that need a special branch to reproduce. This release is different: most of it is on by default, and the one big win is a single flag.

staticRoutes is free speed#

By default, Nuxt creates a fresh vue-router matcher for every server request, in case your app adds routes at runtime. If your routes are fixed at build time, tell Nuxt:

nuxt.config.ts
export default defineNuxtConfig({
  experimental: {
    staticRoutes: true,
  },
});

The server builds the matcher once. On Nuxt's benchmark app with about 170 pages, this more than doubles throughput for a small page: 890 → 1,976 requests per second. The trade-off is that router.addRoute(), removeRoute(), and clearRoutes() throw and disappear from the type of useRouter(). Add routes with the pages:extend hook instead. If you do not add routes at runtime, it is free performance. I enabled it on this site.

A lighter client#

  • ofetch is left out of the client bundle when nothing uses $fetch.
  • unhead is left out when nothing on the client touches the head; if your app has no error.vue, the built-in error page brings it only when it renders.
  • Static useHead() and useSeoMeta() calls in app.vue are hoisted into the server renderer, so SPA shells get them too.
  • <NuxtLink>s with a static internal to compile to a plain anchor in production client builds, with no component instance.
  • The Nuxt UI landing page hydrated 15% faster (757 → 644 ms) and cut total blocking time 35% (276 → 180 ms).

Faster hydration and rendering#

Nuxt adds V8 compile hints to the entry, layout, and page chunks, so Chrome compiles them off the main thread while they download. In the measurements in the PR, hydration of a heavy landing page went from 477 ms to 311 ms, and total blocking time from 137 ms to 40 ms. The browser also paints before hydrating, and hydration yields between boot phases instead of running one long task.

On the server, rendered HTML is encoded chunk by chunk. A single → in a template used to make V8 encode the whole document as a two-byte string. Small fix, surprising impact.

The build and dev loop#

  • With experimental.viteEnvironmentApi (or compatibilityVersion: 5), the client and server build at the same time, about 11% faster on a starter.
  • Auto-imported components are resolved inside the Vue template compiler instead of a separate pass.
  • Babel only runs on server files that actually contain a decorator, making builds about 30% faster with experimental.decorators.
  • nuxt.schema files load natively without jiti: about 100 ms to 3 ms.
  • A request that is still rendering when the server rebuilds now finishes on the old code instead of failing with a 503.

And Nuxt CLI 4.1 now renders the whole production build itself from a set of new build hooks. nuxt build shows one coherent build instead of each tool's logs one after another, with the same output for Vite, webpack, Rspack, and Rsbuild. nuxt generate lists the prerendered routes and ends by suggesting where to deploy. nuxt dev --https serves over HTTP/2, so modules load in parallel on one connection.


The rest of the toolbox#

A few smaller things I do not want to lose:

  • Rsbuild builder. @nuxt/rsbuild-builder hands the build to Rsbuild itself. It replaces @nuxt/rspack-builder, which is deprecated but still works. Set builder: 'rsbuild'.
  • Renderer plugins for module authors. addRendererPlugin() attaches to the renderer instead of a particular server, so it works with Nitro v2, Nitro v3, and @nuxt/vite-server. There is also a new render:document hook with the finished HTML of a non-streamed response.
  • defineHandler from nuxt/server. The Nitro v3 name, with defineEventHandler as an alias. Same portable handler, one less rename on the way to Nuxt 5.
  • serverFetch is typed against your server routes. Internal calls finally know what they are calling.
  • addRouteMiddleware returns an unregister function. Onboarding middleware can remove itself when the user is done.
  • navigateTo(url, { open }) can pass noopener by default. On with compatibilityVersion: 5, or set experimental.defaults.navigateTo.noopener: true. The opened page cannot reach back through window.opener.
  • sourcemap: { client: 'nosource' } generates source maps without your original source, so you can publish them safely.
  • <NuxtLoadingIndicator> has a finish-color prop. Small, but I have wanted it.

Security: upgrade, then purge#

This release also fixes security issues, and one of them has a cache-shaped tail. The advisories are linked in the release notes; the short version:

  • Route rules on _payload.json (GHSA-jxc9-w3j6-pwp2, medium). If you use a wildcard cache, swr, or isr rule together with a more specific rule for a page — for example cache: false for an authenticated section — a request for the page's _payload.json could be matched by the wildcard only. One user's page data could be cached and served to another.
  • Encoded slashes on catch-all routes (GHSA-vrh2-cfcx-c3fg, medium). An incomplete fix for an earlier advisory. If you rely on route rules for a catch-all page such as pages/[...slug].vue, a repeated or leading encoded slash could bypass them.
  • Dev server runtime config (GHSA-h5xj-x893-p5f7, low, development only). If you run nuxt dev reachable from an untrusted network, private runtime config could be read from earlier Nitro build output.

If you use cache, swr, or isr route rules on pages with user-specific data, purge any CDN or edge cache that may already hold a _payload.json after you upgrade. Upgrading the code does not evict the old entries.


Before you upgrade#

None of these should break your app, but they are worth knowing:

  • Nuxt DevTools is no longer installed with Nuxt. Add @nuxt/devtools to devDependencies, or click the button nuxt dev shows you. Fresh installs are smaller; you pick v3 or v4.
  • Nuxt warns when your vue is older than it needs (NUXT_B7042). 4.7 requires vue ^3.5.46. npx nuxt upgrade --dedupe updates it with Nuxt.
  • Template diagnostics are on. You may see new NUXT_B4025 warnings for links to pages that do not exist. If a link points at a server route, a file in public/, or another site, add the external prop.
  • With experimental.viteEnvironmentApi, the client and server build in parallel. If a Vite plugin reads the client build output from the server build, set experimental.parallelBuild: false.
  • globalThis.$fetch is only installed on the client when something uses it. If you read it from the browser console, an inline script, or a file in public/, set experimental.globalFetch: true.
  • @nuxt/rspack-builder is deprecated in favour of @nuxt/rsbuild-builder.
  • <NuxtClientFallback> is deprecated in favour of <NuxtErrorBoundary retry-on-client>.

The upgrade command is still the same:

bash
npx nuxt upgrade --dedupe

It refreshes the lockfile and pulls in Nuxt CLI 4.1, my-bad v1, and vite-plugin-checker v1.


Why this release matters#

I keep coming back to the same idea: Nuxt 4.7 is a release about confidence.

Nitro v3 under Nuxt means you can find your Nuxt 5 server problems now, on a minor, with a compatibility layer that explains itself. WebMCP means you can experiment with the agentic web without inventing a second UI for machines. The problems drawer and template diagnostics mean the framework tells you what is wrong before your users do. Validated runtime config means a missing secret stops the boot, not the checkout. staticRoutes means the boring optimization is one flag.

None of that is a keynote demo. It is the work of a team that would rather make the next major safe than make this minor loud.

Last year I wrote that maintainership compounds. 4.7 is the interest payment. The runway is still a runway — Nuxt 5 is not here — but for the first time we are moving down it, and the engine underneath is the one we will use when we take off.

If you want the hands-on version of this release, I turned it into a seven-step run: Learning Nuxt 4.7. And if you want to meet Nitro v3 without Nuxt in the room, the depot is open: Nitro v3 in Practice: Build Ampyard.

Thank you to Daniel Roe, the Nuxt team, and everyone who tested Nitro v3 on a branch so the rest of us could see the road. 💚

Letters from the field

The next essay, in your inbox.

New essays and build notes, sent when there is something worth saying. No feed, no noise.

No noise. Unsubscribe any time.

Comments

Questions, corrections, and war stories are welcome. Sign in to join the thread.

Discussion

0

Loading the thread…