@nuxt/docs-nightly 4.6.4-2611201615-5635721 → 4.6.4-2611201708-0d5ff9b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -129,6 +129,8 @@ export default defineNuxtConfig({
|
|
|
129
129
|
|
|
130
130
|
With [`future.compatibilityVersion: 5`](#testing-nuxt-5), the layer is off unless you enable it, as it is on Nuxt 5.
|
|
131
131
|
|
|
132
|
+
If you set `experimental.nitroAutoImports: false` and don't set `nitroLegacy`, the layer leaves its auto-imports off (`nitroLegacy.imports`), so your server code must import h3 and Nitro helpers explicitly, and files in subdirectories of `server/utils/` aren't auto-imported.
|
|
133
|
+
|
|
132
134
|
### What Changes With Nitro v3
|
|
133
135
|
|
|
134
136
|
The layer keeps Nitro v2 code resolving and running. It doesn't restore every behavior of Nitro v2 and h3 v1, so these differences remain:
|
|
@@ -146,6 +148,25 @@ The layer keeps Nitro v2 code resolving and running. It doesn't restore every be
|
|
|
146
148
|
|
|
147
149
|
The remaining changes are listed under [Migration to Nitro v3](https://nuxt.com/docs/5.x/getting-started/upgrade#migration-to-nitro-v3) in the Nuxt 5 upgrade guide.
|
|
148
150
|
|
|
151
|
+
### Route Rule Patterns
|
|
152
|
+
|
|
153
|
+
Nitro v3 matches [route rules](/docs/guide/concepts/rendering#hybrid-rendering) with a different pattern syntax. The new syntax applies to every rule, including rules that layers and modules add and rules set in a `nitro:config` hook, and `nitroLegacy` doesn't restore the old one. Your app uses the same syntax as the server, so `ssr`, `redirect`, `appMiddleware`, `appLayout`, `noScripts`, `prerender`, and the payload of cached routes apply to the same paths on both. With Nitro v2, route rules match as before.
|
|
154
|
+
|
|
155
|
+
These patterns match different paths with Nitro v3:
|
|
156
|
+
|
|
157
|
+
- **A single `*`** matches any number of segments rather than exactly one, so `/blog/*` also applies to `/blog/2026/hello`. This is also the case for a `*` inside a segment, such as `/files/report.*`, a `*` followed by more of the pattern, such as `/docs/*/edit`, and a `(.*)` constraint, such as `/docs/:path(.*)`. To match a single segment, use a named parameter: `/blog/:slug` matches `/blog/hello`, and `/blog/:slug?` also matches `/blog`.
|
|
158
|
+
- **A `**` followed by more of the pattern** requires the rest of the pattern, so `/docs/**/edit` matches `/docs/intro/edit` but no longer matches `/docs/intro`.
|
|
159
|
+
- **A parameter name** ends at the first character that isn't a letter, a digit, or `_`. `/users/:user-id` is the parameter `:user` followed by the text `-id`, so it matches only segments that end with `-id`. Rename the parameter, for example to `:userId`.
|
|
160
|
+
- **A catch-all parameter**, such as `/files/:path+` or `/files/**:path`, doesn't match a path with an empty segment, such as `/files/a//b`.
|
|
161
|
+
|
|
162
|
+
With Nitro v3, a rule key can start with an HTTP method, such as `GET /api/report`, and the server applies the rule only to requests with that method. Your app, during server rendering and client navigation, follows the rules that apply to `GET` requests, so a rule scoped to another method has no effect in the app. Nitro v2 doesn't support method-scoped keys and reads such a key as a literal path.
|
|
163
|
+
|
|
164
|
+
The build reports `NUXT_B4029` for each rule key that uses one of the first three patterns. The warning names the key, which may come from a module rather than from your `nuxt.config`. A pattern with more than one `*`, `**`, `:name+`, or `:name*`, or a regex constraint with a capturing group, an anchor, or a look-around, fails the build.
|
|
165
|
+
|
|
166
|
+
Review the scope of your route rules when you switch, and in particular rules that set headers, `cache`, `swr`, `isr`, `redirect`, `proxy`, `prerender`, `ssr`, or `appMiddleware`. A rule can apply to more paths, or to fewer, than it did with Nitro v2.
|
|
167
|
+
|
|
168
|
+
The [route rules section](https://nuxt.com/docs/5.x/getting-started/upgrade#route-rules-matches-nested-paths) of the Nuxt 5 upgrade guide covers the same change, and the [rou3 migration guide](https://github.com/h3js/rou3/blob/main/docs/migration.md) lists every change to the pattern syntax.
|
|
169
|
+
|
|
149
170
|
## Moving to `nuxt/server`
|
|
150
171
|
|
|
151
172
|
From Nuxt 4.6, server code can import its handler and helpers from [`nuxt/server`](/docs/guide/going-further/server-imports) rather than from h3, so the same file runs on Nuxt 4 (`nitropack` v2 and h3 v1) and on [Nuxt 5](https://nuxt.com/docs/5.x/getting-started/upgrade) (Nitro v3 and h3 v2).
|
package/4.api/6.nuxt-config.md
CHANGED
|
@@ -993,12 +993,12 @@ While any switch is on, an error thrown with its own `statusCode`, such as `{ st
|
|
|
993
993
|
|
|
994
994
|
In the same cases, Nuxt emits the Nitro v2 `beforeResponse`, `afterResponse`, `render:before` and `render:response` hooks. Nitro v2 plugins that the layer covers, and `useNitroApp()` imported from `nitropack/runtime`, get a `nitroApp.hooks.callHook()` that always returns a promise.
|
|
995
995
|
|
|
996
|
-
The option has no effect when Nuxt builds your server with Nitro v2 (`nitropack`). It's on by default when your project depends on `nitro`, so that Nuxt builds the server with Nitro v3, unless `future.compatibilityVersion` is `5`.
|
|
996
|
+
The option has no effect when Nuxt builds your server with Nitro v2 (`nitropack`). It's on by default when your project depends on `nitro`, so that Nuxt builds the server with Nitro v3, unless `future.compatibilityVersion` is `5`. If you set `experimental.nitroAutoImports: false` and leave `nitroLegacy` unset, the default is `{ imports: false }`, which keeps every other switch on.
|
|
997
997
|
|
|
998
998
|
This option and the compatibility layer will be removed in Nuxt 6.
|
|
999
999
|
|
|
1000
1000
|
- **Type**: `boolean | object`
|
|
1001
|
-
- **Default:** `true` with Nitro v3 and a `future.compatibilityVersion` below `5
|
|
1001
|
+
- **Default:** `true` with Nitro v3 and a `future.compatibilityVersion` below `5` (`{ imports: false }` when `experimental.nitroAutoImports` is `false`), otherwise `false`
|
|
1002
1002
|
|
|
1003
1003
|
**See**: [Nitro v2 compatibility](/docs/getting-started/upgrade#nitro-v2-compatibility)
|
|
1004
1004
|
|