@nuxt/docs-nightly 4.0.0-29204565.30a3cc6d → 4.0.0-29207326.36a6df78

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.
@@ -34,76 +34,37 @@ bun x nuxt upgrade
34
34
 
35
35
  To use the latest Nuxt build and test features before their release, read about the [nightly release channel](/docs/guide/going-further/nightly-release-channel) guide.
36
36
 
37
- ::warning
38
- The nightly release channel `latest` tag is currently tracking the Nuxt v4 branch, meaning that it is particularly likely to have breaking changes right now — be careful! You can opt in to the 3.x branch nightly releases with `"nuxt": "npm:nuxt-nightly@3x"`.
39
- ::
40
-
41
- ## Testing Nuxt 4
37
+ ## Migrating to Nuxt 4
42
38
 
43
- Nuxt 4 is **scheduled for release in Q2 2025**. It will include all the features currently available through `compatibilityVersion: 4`.
39
+ Nuxt 4 includes significant improvements and changes. This guide will help you migrate your existing Nuxt 3 application to Nuxt 4.
44
40
 
45
- Until the release, it is possible to test many of Nuxt 4's breaking changes from Nuxt version 3.12+.
41
+ First, upgrade to Nuxt 4:
46
42
 
47
- :video-accordion{title="Watch a video from Alexander Lichter showing how to opt in to Nuxt 4's breaking changes already" videoId="r4wFKlcJK6c"}
43
+ ::code-group{sync="pm"}
48
44
 
49
- ### Opting in to Nuxt 4
45
+ ```bash [npm]
46
+ npm install nuxt@^4.0.0-rc
47
+ ```
50
48
 
51
- First, upgrade Nuxt to the [latest release](https://github.com/nuxt/nuxt/releases).
49
+ ```bash [yarn]
50
+ yarn add nuxt@^4.0.0-rc
51
+ ```
52
52
 
53
- Then you can set your `compatibilityVersion` to match Nuxt 4 behavior:
53
+ ```bash [pnpm]
54
+ pnpm add nuxt@^4.0.0-rc
55
+ ```
54
56
 
55
- ::code-collapse
56
- ```ts twoslash [nuxt.config.ts]
57
- export default defineNuxtConfig({
58
- future: {
59
- compatibilityVersion: 4,
60
- },
61
- // To re-enable _all_ Nuxt v3 behavior, set the following options:
62
- // srcDir: '.',
63
- // dir: {
64
- // app: 'app'
65
- // },
66
- // experimental: {
67
- // scanPageMeta: 'after-resolve',
68
- // sharedPrerenderData: false,
69
- // compileTemplate: true,
70
- // resetAsyncDataToUndefined: true,
71
- // templateUtils: true,
72
- // relativeWatchPaths: true,
73
- // normalizeComponentNames: false,
74
- // spaLoadingTemplateLocation: 'within',
75
- // parseErrorData: false,
76
- // pendingWhenIdle: true,
77
- // alwaysRunFetchOnKeyChange: true,
78
- // defaults: {
79
- // useAsyncData: {
80
- // deep: true
81
- // }
82
- // }
83
- // },
84
- // features: {
85
- // inlineStyles: true
86
- // },
87
- // unhead: {
88
- // renderSSRHeadOptions: {
89
- // omitLineBreaks: false
90
- // }
91
- // }
92
- })
57
+ ```bash [bun]
58
+ bun add nuxt@^4.0.0-rc
93
59
  ```
94
- ::
95
60
 
96
- ::note
97
- For now, you need to define the compatibility version in each layer that opts into Nuxt 4 behavior. This will not be required after Nuxt 4 is released.
98
61
  ::
99
62
 
100
- When you set your `compatibilityVersion` to `4`, defaults throughout your Nuxt configuration will change to opt in to Nuxt v4 behavior, but you can granularly re-enable Nuxt v3 behavior when testing, following the commented out lines above. Please file issues if so, so that we can address them in Nuxt or in the ecosystem.
63
+ After upgrading, most Nuxt 4 behaviors are now the default. However, some features can still be configured if you need to maintain backward compatibility during your migration.
101
64
 
102
- Breaking or significant changes will be noted here along with migration steps for backward/forward compatibility.
65
+ The following sections detail the key changes and migrations needed when upgrading to Nuxt 4.
103
66
 
104
- ::note
105
- This section is subject to change until the final release, so please check back here regularly if you are testing Nuxt 4 using `compatibilityVersion: 4`.
106
- ::
67
+ Breaking or significant changes are documented below along with migration steps and available configuration options.
107
68
 
108
69
  ### Migrating Using Codemods
109
70
 
@@ -303,6 +264,64 @@ export default defineNuxtConfig({
303
264
  })
304
265
  ```
305
266
 
267
+ ### Corrected Module Loading Order in Layers
268
+
269
+ 🚦 **Impact Level**: Minimal
270
+
271
+ #### What Changed
272
+
273
+ The order in which modules are loaded when using [Nuxt layers](/docs/guide/going-further/layers) has been corrected. Previously, modules from the project root were loaded before modules from extended layers, which was the reverse of the expected behavior.
274
+
275
+ Now modules are loaded in the correct order:
276
+
277
+ 1. **Layer modules first** (in extend order - deeper layers first)
278
+ 2. **Project modules last** (highest priority)
279
+
280
+ This affects both:
281
+ * Modules defined in the `modules` array in `nuxt.config.ts`
282
+ * Auto-discovered modules from the `modules/` directory
283
+
284
+ #### Reasons for Change
285
+
286
+ This change ensures that:
287
+ * Extended layers have lower priority than the consuming project
288
+ * Module execution order matches the intuitive layer inheritance pattern
289
+ * Module configuration and hooks work as expected in multi-layer setups
290
+
291
+ #### Migration Steps
292
+
293
+ **Most projects will not need changes**, as this corrects the loading order to match expected behavior.
294
+
295
+ However, if your project was relying on the previous incorrect order, you may need to:
296
+
297
+ 1. **Review module dependencies**: Check if any modules depend on specific loading order
298
+ 2. **Adjust module configuration**: If modules were configured to work around the incorrect order
299
+ 3. **Test thoroughly**: Ensure all functionality works as expected with the corrected order
300
+
301
+ Example of the new correct order:
302
+ ```ts
303
+ // Layer: my-layer/nuxt.config.ts
304
+ export default defineNuxtConfig({
305
+ modules: ['layer-module-1', 'layer-module-2']
306
+ })
307
+
308
+ // Project: nuxt.config.ts
309
+ export default defineNuxtConfig({
310
+ extends: ['./my-layer'],
311
+ modules: ['project-module-1', 'project-module-2']
312
+ })
313
+
314
+ // Loading order (corrected):
315
+ // 1. layer-module-1
316
+ // 2. layer-module-2
317
+ // 3. project-module-1 (can override layer modules)
318
+ // 4. project-module-2 (can override layer modules)
319
+ ```
320
+
321
+ If you encounter issues with module order dependencies due to needing to register a hook, consider using the [`modules:done` hook](/docs/guide/going-further/modules#custom-hooks) for modules that need to call a hook. This is run after all other modules have been loaded, which means it is safe to use.
322
+
323
+ 👉 See [PR #31507](https://github.com/nuxt/nuxt/pull/31507) and [issue #25719](https://github.com/nuxt/nuxt/issues/25719) for more details.
324
+
306
325
  ### Deduplication of Route Metadata
307
326
 
308
327
  🚦 **Impact Level**: Minimal
@@ -490,16 +509,6 @@ Update your custom `error.vue` to remove any additional parsing of `error.data`:
490
509
  </script>
491
510
  ```
492
511
 
493
- Alternatively, you can disable this change:
494
-
495
- ```ts twoslash [nuxt.config.ts]
496
- export default defineNuxtConfig({
497
- experimental: {
498
- parseErrorData: false
499
- },
500
- })
501
- ```
502
-
503
512
  ### More Granular Inline Styles
504
513
 
505
514
  🚦 **Impact Level**: Moderate
@@ -697,21 +706,6 @@ If you provide a custom `default` value for `useAsyncData`, this will now be use
697
706
 
698
707
  Often users set an appropriately empty value, such as an empty array, to avoid the need to check for `null`/`undefined` when iterating over it. This should be respected when resetting/clearing the data.
699
708
 
700
- #### Migration Steps
701
-
702
- If you encounter any issues you can revert back to the previous behavior, for now, with:
703
-
704
- ```ts twoslash [nuxt.config.ts]
705
- // @errors: 2353
706
- export default defineNuxtConfig({
707
- experimental: {
708
- resetAsyncDataToUndefined: true,
709
- }
710
- })
711
- ```
712
-
713
- Please report an issue if you are doing so, as we do not plan to keep this as configurable.
714
-
715
709
  ### Alignment of `pending` value in `useAsyncData` and `useFetch`
716
710
 
717
711
  🚦 **Impact Level**: Medium
@@ -15,12 +15,6 @@ The `shared/` directory is available in Nuxt v3.14+.
15
15
  Code in the `shared/` directory cannot import any Vue or Nitro code.
16
16
  ::
17
17
 
18
- ::warning
19
- Auto-imports are not enabled by default in Nuxt v3 to prevent breaking changes in existing projects.
20
-
21
- To use these auto-imported utils and types, you must first [set `future.compatibilityVersion: 4` in your `nuxt.config.ts`](/docs/getting-started/upgrade#opting-in-to-nuxt-4).
22
- ::
23
-
24
18
  :video-accordion{title="Watch a video from Vue School on sharing utils and types between app and server" videoId="nnAR-MO3q5M"}
25
19
 
26
20
  ## Usage
@@ -58,25 +58,6 @@ await nuxtApp.callHook('app:user:registered', {
58
58
  You can inspect all events using the **Nuxt DevTools** Hooks panel.
59
59
  ::
60
60
 
61
- ## Augmenting Types
62
-
63
- You can augment the types of hooks provided by Nuxt.
64
-
65
- ```ts
66
- import { HookResult } from "@nuxt/schema";
67
-
68
- declare module '#app' {
69
- interface RuntimeNuxtHooks {
70
- 'your-nuxt-runtime-hook': () => HookResult
71
- }
72
- interface NuxtHooks {
73
- 'your-nuxt-hook': () => HookResult
74
- }
75
- }
76
-
77
- declare module 'nitropack/types' {
78
- interface NitroRuntimeHooks {
79
- 'your-nitro-hook': () => void;
80
- }
81
- }
82
- ```
61
+ ::read-more{to="/docs/guide/going-further/hooks"}
62
+ Learn more about Nuxt's built-in hooks and how to extend them
63
+ ::
@@ -3,7 +3,7 @@ title: "Experimental Features"
3
3
  description: "Enable Nuxt experimental features to unlock new possibilities."
4
4
  ---
5
5
 
6
- The Nuxt experimental features can be enabled in the Nuxt configuration file.
6
+ Nuxt includes experimental features that you can enable in your configuration file.
7
7
 
8
8
  Internally, Nuxt uses `@nuxt/schema` to define these experimental features. You can refer to the [API documentation](/docs/api/configuration/nuxt-config#experimental) or the [source code](https://github.com/nuxt/nuxt/blob/main/packages/schema/src/config/experimental.ts) for more information.
9
9
 
@@ -284,14 +284,14 @@ export default defineNuxtConfig({
284
284
 
285
285
  ## sharedPrerenderData
286
286
 
287
- Enabling this feature automatically shares payload *data* between pages that are prerendered. This can result
288
- in a significant performance improvement when prerendering sites that use `useAsyncData` or `useFetch` and
289
- fetch the same data in different pages.
287
+ Nuxt automatically shares payload *data* between pages that are prerendered. This can result in a significant performance improvement when prerendering sites that use `useAsyncData` or `useFetch` and fetch the same data in different pages.
288
+
289
+ You can disable this feature if needed.
290
290
 
291
291
  ```ts twoslash [nuxt.config.ts]
292
292
  export default defineNuxtConfig({
293
293
  experimental: {
294
- sharedPrerenderData: true
294
+ sharedPrerenderData: false
295
295
  }
296
296
  })
297
297
  ```
@@ -332,11 +332,11 @@ globalThis.Buffer = globalThis.Buffer || Buffer
332
332
 
333
333
  ## scanPageMeta
334
334
 
335
- This option allows exposing some route metadata defined in `definePageMeta` at build-time to modules (specifically `alias`, `name`, `path`, `redirect`, `props` and `middleware`).
335
+ Nuxt exposing some route metadata defined in `definePageMeta` at build-time to modules (specifically `alias`, `name`, `path`, `redirect`, `props` and `middleware`).
336
336
 
337
337
  This only works with static or strings/arrays rather than variables or conditional assignment. See [original issue](https://github.com/nuxt/nuxt/issues/24770) for more information and context.
338
338
 
339
- It is also possible to scan page metadata only after all routes have been registered in `pages:extend`. Then another hook, `pages:resolved` will be called. To enable this behavior, set `scanPageMeta: 'after-resolve'`.
339
+ By default page metadata is only scanned after all routes have been registered in `pages:extend`. Then another hook, `pages:resolved` will be called.
340
340
 
341
341
  You can disable this feature if it causes issues in your project.
342
342
 
@@ -427,13 +427,14 @@ This allows modules to access additional metadata from the page metadata in the
427
427
 
428
428
  ## normalizeComponentNames
429
429
 
430
- Ensure that auto-generated Vue component names match the full component name
431
- you would use to auto-import the component.
430
+ Nuxt updates auto-generated Vue component names to match the full component name you would use to auto-import the component.
431
+
432
+ If you encounter issues, you can disable this feature.
432
433
 
433
434
  ```ts twoslash [nuxt.config.ts]
434
435
  export default defineNuxtConfig({
435
436
  experimental: {
436
- normalizeComponentNames: true
437
+ normalizeComponentNames: false
437
438
  }
438
439
  })
439
440
  ```
@@ -39,51 +39,9 @@ There is also a `future` namespace for early opting-in to new features that will
39
39
 
40
40
  ### compatibilityVersion
41
41
 
42
- ::important
43
- This configuration option is available in Nuxt v3.12+. Please note, that for now, you need to define the compatibility version in each layer that opts into Nuxt 4 behavior. This will not be required after Nuxt 4 is released.
44
- ::
42
+ This is used for enabling early access to Nuxt features or flags.
45
43
 
46
- This enables early access to Nuxt features or flags.
47
-
48
- Setting `compatibilityVersion` to `4` changes defaults throughout your
49
- Nuxt configuration to opt-in to Nuxt v4 behaviour, but you can granularly re-enable Nuxt v3 behaviour
50
- when testing (see example). Please file issues if so, so that we can
51
- address in Nuxt or in the ecosystem.
52
-
53
- ```ts
54
- export default defineNuxtConfig({
55
- future: {
56
- compatibilityVersion: 4,
57
- },
58
- // To re-enable _all_ Nuxt v3 behaviour, set the following options:
59
- srcDir: '.',
60
- dir: {
61
- app: 'app'
62
- },
63
- experimental: {
64
- scanPageMeta: 'after-resolve',
65
- sharedPrerenderData: false,
66
- compileTemplate: true,
67
- resetAsyncDataToUndefined: true,
68
- templateUtils: true,
69
- relativeWatchPaths: true,
70
- normalizeComponentNames: false
71
- defaults: {
72
- useAsyncData: {
73
- deep: true
74
- }
75
- }
76
- },
77
- features: {
78
- inlineStyles: true
79
- },
80
- unhead: {
81
- renderSSRHeadOptions: {
82
- omitLineBreaks: false
83
- }
84
- }
85
- })
86
- ```
44
+ It is not configurable yet in Nuxt 4, but once we begin merging breaking changes for v5, it will be possible to enable it.
87
45
 
88
46
  ### typescriptBundlerResolution
89
47
 
@@ -74,6 +74,25 @@ export default defineNitroPlugin((nitroApp) => {
74
74
  Learn more about available Nitro lifecycle hooks.
75
75
  ::
76
76
 
77
- ## Additional Hooks
77
+ ## Adding Custom Hooks
78
78
 
79
- Learn more about creating custom hooks in the [Events section](/docs/guide/going-further/events).
79
+ You can define your own custom hooks support by extending Nuxt's hook interfaces.
80
+
81
+ ```ts
82
+ import { HookResult } from "@nuxt/schema";
83
+
84
+ declare module '#app' {
85
+ interface RuntimeNuxtHooks {
86
+ 'your-nuxt-runtime-hook': () => HookResult
87
+ }
88
+ interface NuxtHooks {
89
+ 'your-nuxt-hook': () => HookResult
90
+ }
91
+ }
92
+
93
+ declare module 'nitropack/types' {
94
+ interface NitroRuntimeHooks {
95
+ 'your-nitro-hook': () => void;
96
+ }
97
+ }
98
+ ```
@@ -214,51 +214,3 @@ export default defineNuxtPlugin({
214
214
  ```
215
215
 
216
216
  ::
217
-
218
- #### Using an EJS template to generate a plugin
219
-
220
- You can also use an EJS template to generate your plugin. Options can be passed through the `options` property and then used within the EJS template to generate the plugin content.
221
-
222
- ::code-group
223
-
224
- ```ts [module.ts]
225
- import { addPluginTemplate, createResolver, defineNuxtModule } from '@nuxt/kit'
226
-
227
- export default defineNuxtModule({
228
- setup (options, nuxt) {
229
- const { resolve } = createResolver(import.meta.url)
230
-
231
- addPluginTemplate({
232
- src: resolve('templates/plugin.ejs'),
233
- filename: 'plugin.mjs',
234
- options: {
235
- ssr: nuxt.options.ssr,
236
- },
237
- })
238
- },
239
- })
240
- ```
241
-
242
- ```ts [templates/plugin.ejs]
243
- import { VueFire, useSSRInitialState } from 'vuefire'
244
- import { defineNuxtPlugin } from '#imports'
245
-
246
- export default defineNuxtPlugin((nuxtApp) => {
247
- const firebaseApp = nuxtApp.$firebaseApp
248
- nuxtApp.vueApp.use(VueFire, { firebaseApp })
249
-
250
- <% if(options.ssr) { %>
251
- if (import.meta.server) {
252
- nuxtApp.payload.vuefire = useSSRInitialState(undefined, firebaseApp)
253
- } else if (nuxtApp.payload?.vuefire) {
254
- useSSRInitialState(nuxtApp.payload.vuefire, firebaseApp)
255
- }
256
- <% } %>
257
- })
258
- ```
259
-
260
- ::
261
-
262
- ::warning
263
- If you set `compatibilityVersion` to `4`, Nuxt no longer uses `lodash.template` to compile templates by default. You can still enable it via the `experimental.compileTemplate` option, but support for EJS templates will be removed entirely in the next major version.
264
- ::
@@ -1281,42 +1281,9 @@ If set to 'production' or `true`, JS will be disabled in production mode only.
1281
1281
 
1282
1282
  ### `compatibilityVersion`
1283
1283
 
1284
- Enable early access to Nuxt v4 features or flags.
1284
+ This is used for enabling early access to Nuxt features or flags.
1285
1285
 
1286
- Setting `compatibilityVersion` to `4` changes defaults throughout your Nuxt configuration, but you can granularly re-enable Nuxt v3 behaviour when testing (see example). Please file issues if so, so that we can address in Nuxt or in the ecosystem.
1287
-
1288
- - **Type**: `number`
1289
- - **Default:** `3`
1290
-
1291
- **Example**:
1292
- ```ts
1293
- export default defineNuxtConfig({
1294
- future: {
1295
- compatibilityVersion: 4,
1296
- },
1297
- // To re-enable _all_ Nuxt v3 behaviour, set the following options:
1298
- srcDir: '.',
1299
- dir: {
1300
- app: 'app'
1301
- },
1302
- experimental: {
1303
- compileTemplate: true,
1304
- templateUtils: true,
1305
- relativeWatchPaths: true,
1306
- resetAsyncDataToUndefined: true,
1307
- defaults: {
1308
- useAsyncData: {
1309
- deep: true
1310
- }
1311
- }
1312
- },
1313
- unhead: {
1314
- renderSSRHeadOptions: {
1315
- omitLineBreaks: false
1316
- }
1317
- }
1318
- })
1319
- ```
1286
+ It is not configurable yet in Nuxt 4, but once we begin merging breaking changes for v5, it will be possible to enable it.
1320
1287
 
1321
1288
  ### `multiApp`
1322
1289
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/docs-nightly",
3
- "version": "4.0.0-29204565.30a3cc6d",
3
+ "version": "4.0.0-29207326.36a6df78",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",