@nuxt/docs 4.0.0-rc.0 → 4.0.1

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.
Files changed (39) hide show
  1. package/1.getting-started/01.introduction.md +2 -2
  2. package/1.getting-started/02.installation.md +2 -2
  3. package/1.getting-started/03.configuration.md +1 -1
  4. package/1.getting-started/04.views.md +1 -1
  5. package/1.getting-started/06.styling.md +3 -3
  6. package/1.getting-started/08.seo-meta.md +2 -2
  7. package/1.getting-started/09.transitions.md +3 -3
  8. package/1.getting-started/10.data-fetching.md +3 -3
  9. package/1.getting-started/12.error-handling.md +1 -1
  10. package/1.getting-started/15.prerendering.md +2 -2
  11. package/1.getting-started/16.deployment.md +1 -1
  12. package/1.getting-started/17.testing.md +1 -1
  13. package/1.getting-started/18.upgrade.md +115 -86
  14. package/2.guide/0.index.md +3 -0
  15. package/2.guide/1.concepts/3.rendering.md +1 -1
  16. package/2.guide/2.directory-structure/1.app/1.components.md +1 -1
  17. package/2.guide/2.directory-structure/1.app/1.pages.md +1 -1
  18. package/2.guide/2.directory-structure/1.shared.md +0 -6
  19. package/2.guide/3.going-further/1.events.md +3 -22
  20. package/2.guide/3.going-further/1.experimental-features.md +11 -10
  21. package/2.guide/3.going-further/1.features.md +2 -44
  22. package/2.guide/3.going-further/2.hooks.md +21 -2
  23. package/2.guide/3.going-further/3.modules.md +27 -2
  24. package/2.guide/5.best-practices/.navigation.yml +3 -0
  25. package/2.guide/5.best-practices/performance.md +305 -0
  26. package/2.guide/5.best-practices/plugins.md +20 -0
  27. package/3.api/2.composables/use-async-data.md +4 -0
  28. package/3.api/2.composables/use-fetch.md +4 -0
  29. package/3.api/2.composables/use-response-header.md +1 -1
  30. package/3.api/2.composables/use-runtime-config.md +1 -1
  31. package/3.api/3.utils/$fetch.md +1 -1
  32. package/3.api/4.commands/init.md +2 -0
  33. package/3.api/5.kit/10.templates.md +1 -1
  34. package/3.api/5.kit/9.plugins.md +0 -48
  35. package/3.api/6.advanced/1.hooks.md +4 -4
  36. package/3.api/6.nuxt-config.md +9 -40
  37. package/7.migration/6.pages-and-layouts.md +1 -1
  38. package/7.migration/8.runtime-config.md +1 -1
  39. package/package.json +1 -1
@@ -24,7 +24,7 @@ Nuxt uses conventions and an opinionated directory structure to automate repetit
24
24
  - **Server-side rendering out of the box:** Nuxt comes with built-in SSR capabilities, so you don't have to set up a separate server yourself.
25
25
  - **Auto-imports:** write Vue composables and components in their respective directories and use them without having to import them with the benefits of tree-shaking and optimized JS bundles.
26
26
  - **Data-fetching utilities:** Nuxt provides composables to handle SSR-compatible data fetching as well as different strategies.
27
- - **Zero-config TypeScript support:** write type-safe code without having to learn TypeScript with our auto-generated types and `tsconfig.json`
27
+ - **Zero-config TypeScript support:** write type-safe code without having to learn TypeScript with our auto-generated types and `tsconfig.json`.
28
28
  - **Configured build tools:** we use [Vite](https://vite.dev) by default to support hot module replacement (HMR) in development and bundling your code for production with best-practices baked-in.
29
29
 
30
30
  Nuxt takes care of these and provides both frontend and backend functionality so you can focus on what matters: **creating your web application**.
@@ -64,7 +64,7 @@ A Nuxt application can be deployed on a Node or Deno server, pre-rendered to be
64
64
 
65
65
  ### Modular
66
66
 
67
- A module system allows to extend Nuxt with custom features and integrations with third-party services.
67
+ A module system allows you to extend Nuxt with custom features and integrations with third-party services.
68
68
 
69
69
  :read-more{title="Nuxt Modules Concept" to="/docs/guide/concepts/modules"}
70
70
 
@@ -9,8 +9,8 @@ navigation.icon: i-lucide-play
9
9
  If you just want to play around with Nuxt in your browser without setting up a project, you can use one of our online sandboxes:
10
10
 
11
11
  ::card-group
12
- :card{title="Open on StackBlitz" icon="i-simple-icons-stackblitz" to="https://nuxt.new/s/v3" target="_blank"}
13
- :card{title="Open on CodeSandbox" icon="i-simple-icons-codesandbox" to="https://nuxt.new/c/v3" target="_blank"}
12
+ :card{title="Open on StackBlitz" icon="i-simple-icons-stackblitz" to="https://nuxt.new/s/v4" target="_blank"}
13
+ :card{title="Open on CodeSandbox" icon="i-simple-icons-codesandbox" to="https://nuxt.new/c/v4" target="_blank"}
14
14
  ::
15
15
 
16
16
  Or follow the steps below to set up a new Nuxt project on your computer.
@@ -100,7 +100,7 @@ const runtimeConfig = useRuntimeConfig()
100
100
 
101
101
  ## App Configuration
102
102
 
103
- The `app.config.ts` file, located in the source directory (by default the root of the project), is used to expose public variables that can be determined at build time. Contrary to the `runtimeConfig` option, these can not be overridden using environment variables.
103
+ The `app.config.ts` file, located in the source directory (by default the root of the project), is used to expose public variables that can be determined at build time. Contrary to the `runtimeConfig` option, these cannot be overridden using environment variables.
104
104
 
105
105
  A minimal configuration file exports the `defineAppConfig` function containing an object with your configuration. The `defineAppConfig` helper is globally available without import.
106
106
 
@@ -88,7 +88,7 @@ To use pages, create `pages/index.vue` file and add `<NuxtPage />` component to
88
88
 
89
89
  ![Layouts are wrapper around pages](/assets/docs/getting-started/views/layouts.svg)
90
90
 
91
- Layouts are wrappers around pages that contain a common User Interface for several pages, such as a header and footer display. Layouts are Vue files using `<slot />` components to display the **page** content. The `layouts/default.vue` file will be used by default. Custom layouts can be set as part of your page metadata.
91
+ Layouts are wrappers around pages that contain a common User Interface for several pages, such as header and footer displays. Layouts are Vue files using `<slot />` components to display the **page** content. The `layouts/default.vue` file will be used by default. Custom layouts can be set as part of your page metadata.
92
92
 
93
93
  ::note
94
94
  If you only have a single layout in your application, we recommend using [`app.vue`](/docs/guide/directory-structure/app) with [`<NuxtPage />`](/docs/api/components/nuxt-page) instead.
@@ -51,7 +51,7 @@ The stylesheets will be inlined in the HTML rendered by Nuxt, injected globally
51
51
 
52
52
  ### Working With Fonts
53
53
 
54
- Place your local fonts files in your `~/public/` directory, for example in `~/public/fonts`. You can then reference them in your stylesheets using `url()`.
54
+ Place your local fonts files in your `public/` directory, for example in `public/fonts`. You can then reference them in your stylesheets using `url()`.
55
55
 
56
56
  ```css [assets/css/main.css]
57
57
  @font-face {
@@ -119,7 +119,7 @@ export default defineNuxtConfig({
119
119
 
120
120
  ## External Stylesheets
121
121
 
122
- You can include external stylesheets in your application by adding a link element in the head section of your nuxt.config file. You can achieve this result using different methods. Note that local stylesheets can also be included like this.
122
+ You can include external stylesheets in your application by adding a link element in the head section of your nuxt.config file. You can achieve this result using different methods. Note that local stylesheets can also be included this way.
123
123
 
124
124
  You can manipulate the head with the [`app.head`](/docs/api/nuxt-config#head) property of your Nuxt configuration:
125
125
 
@@ -409,7 +409,7 @@ You can use [CSS Modules](https://github.com/css-modules/css-modules) with the m
409
409
 
410
410
  ### Preprocessors Support
411
411
 
412
- SFC style blocks support preprocessors syntax. Vite come with built-in support for .scss, .sass, .less, .styl and .stylus files without configuration. You just need to install them first, and they will be available directly in SFC with the lang attribute.
412
+ SFC style blocks support preprocessor syntax. Vite comes with built-in support for .scss, .sass, .less, .styl and .stylus files without configuration. You just need to install them first, and they will be available directly in SFC with the lang attribute.
413
413
 
414
414
  ::code-group
415
415
 
@@ -12,7 +12,7 @@ and numerous configuration options to manage your app's head and SEO meta tags.
12
12
  Providing an [`app.head`](/docs/api/nuxt-config#head) property in your [`nuxt.config.ts`](/docs/guide/directory-structure/nuxt-config) allows you to statically customize the head for your entire app.
13
13
 
14
14
  ::important
15
- This method does not allow you to provide reactive data. We recommend to use `useHead()` in `app.vue`.
15
+ This method does not allow you to provide reactive data. We recommend using `useHead()` in `app.vue`.
16
16
  ::
17
17
 
18
18
  It's good practice to set tags here that won't change such as your site title default, language and favicon.
@@ -75,7 +75,7 @@ useHead({
75
75
  </script>
76
76
  ```
77
77
 
78
- We recommend to take a look at the [`useHead`](/docs/api/composables/use-head) and [`useHeadSafe`](/docs/api/composables/use-head-safe) composables.
78
+ We recommend taking a look at the [`useHead`](/docs/api/composables/use-head) and [`useHeadSafe`](/docs/api/composables/use-head-safe) composables.
79
79
 
80
80
  ## `useSeoMeta`
81
81
 
@@ -16,7 +16,7 @@ You can enable page transitions to apply an automatic transition for all your [p
16
16
  export default defineNuxtConfig({
17
17
  app: {
18
18
  pageTransition: { name: 'page', mode: 'out-in' }
19
- },
19
+ }
20
20
  })
21
21
  ```
22
22
 
@@ -121,7 +121,7 @@ You can enable layout transitions to apply an automatic transition for all your
121
121
  export default defineNuxtConfig({
122
122
  app: {
123
123
  layoutTransition: { name: 'layout', mode: 'out-in' }
124
- },
124
+ }
125
125
  })
126
126
  ```
127
127
 
@@ -470,4 +470,4 @@ export default defineNuxtRouteMiddleware(to => {
470
470
 
471
471
  ### Known Issues
472
472
 
473
- - If you perform data fetching within your page setup functions, that you may wish to reconsider using this feature for the moment. (By design, View Transitions completely freeze DOM updates whilst they are taking place.) We're looking at restrict the View Transition to the final moments before `<Suspense>` resolves, but in the interim you may want to consider carefully whether to adopt this feature if this describes you.
473
+ - If you perform data fetching within your page setup functions, you may wish to reconsider using this feature for the moment. (By design, View Transitions completely freeze DOM updates whilst they are taking place.) We're looking at restricting the View Transition to the final moments before `<Suspense>` resolves, but in the interim you may want to consider carefully whether to adopt this feature if this describes you.
@@ -9,7 +9,7 @@ Nuxt comes with two composables and a built-in library to perform data-fetching
9
9
  In a nutshell:
10
10
 
11
11
  - [`$fetch`](/docs/api/utils/dollarfetch) is the simplest way to make a network request.
12
- - [`useFetch`](/docs/api/composables/use-fetch) is wrapper around `$fetch` that fetches data only once in [universal rendering](/docs/guide/concepts/rendering#universal-rendering).
12
+ - [`useFetch`](/docs/api/composables/use-fetch) is a wrapper around `$fetch` that fetches data only once in [universal rendering](/docs/guide/concepts/rendering#universal-rendering).
13
13
  - [`useAsyncData`](/docs/api/composables/use-async-data) is similar to `useFetch` but offers more fine-grained control.
14
14
 
15
15
  Both `useFetch` and `useAsyncData` share a common set of options and patterns that we will detail in the last sections.
@@ -81,7 +81,7 @@ async function addTodo() {
81
81
 
82
82
  ::warning
83
83
  Beware that using only `$fetch` will not provide [network calls de-duplication and navigation prevention](#the-need-for-usefetch-and-useasyncdata). :br
84
- It is recommended to use `$fetch` for client-side interactions (event based) or combined with [`useAsyncData`](#useasyncdata) when fetching the initial component data.
84
+ It is recommended to use `$fetch` for client-side interactions (event-based) or combined with [`useAsyncData`](#useasyncdata) when fetching the initial component data.
85
85
  ::
86
86
 
87
87
  ::read-more{to="/docs/api/utils/dollarfetch"}
@@ -483,7 +483,7 @@ If you need to change the URL based on a reactive value, you may want to use a [
483
483
 
484
484
  #### Computed URL
485
485
 
486
- Sometimes you may need to compute an URL from reactive values, and refresh the data each time these change. Instead of juggling your way around, you can attach each param as a reactive value. Nuxt will automatically use the reactive value and re-fetch each time it changes.
486
+ Sometimes you may need to compute a URL from reactive values, and refresh the data each time these change. Instead of juggling your way around, you can attach each param as a reactive value. Nuxt will automatically use the reactive value and re-fetch each time it changes.
487
487
 
488
488
  ```vue
489
489
  <script setup lang="ts">
@@ -109,7 +109,7 @@ const handleError = () => clearError({ redirect: '/' })
109
109
  Read more about `error.vue` and its uses.
110
110
  ::
111
111
 
112
- For custom errors we highly recommend to use `onErrorCaptured` composable that can be called in a page/component setup function or `vue:error` runtime nuxt hook that can be configured in a nuxt plugin.
112
+ For custom errors we highly recommend using `onErrorCaptured` composable that can be called in a page/component setup function or `vue:error` runtime nuxt hook that can be configured in a nuxt plugin.
113
113
 
114
114
  ```ts twoslash [plugins/error-handler.ts]
115
115
  export default defineNuxtPlugin(nuxtApp => {
@@ -99,7 +99,7 @@ export default defineNuxtConfig({
99
99
  });
100
100
  ```
101
101
 
102
- ::read-more{to="https://nitro.build/config/#routerules"}
102
+ ::read-more{to="https://nitro.build/config#routerules"}
103
103
  Read more about Nitro's `routeRules` configuration.
104
104
  ::
105
105
 
@@ -177,7 +177,7 @@ export default defineNuxtConfig({
177
177
 
178
178
  ### `prerender:generate` Nitro hook
179
179
 
180
- This is called for each route during prerendering. You can use this for fine grained handling of each route that gets prerendered.
180
+ This is called for each route during prerendering. You can use this for fine-grained handling of each route that gets prerendered.
181
181
 
182
182
  ```ts [nuxt.config.ts]
183
183
  export default defineNuxtConfig({
@@ -62,7 +62,7 @@ By default, the workload gets distributed to the workers with the round robin st
62
62
 
63
63
  ### Learn More
64
64
 
65
- :read-more{to="https://nitro.build/deploy/node" title="the Nitro documentation for node-server preset"}
65
+ :read-more{to="https://nitro.build/deploy/runtimes/node" title="the Nitro documentation for node-server preset"}
66
66
 
67
67
  :video-accordion{title="Watch Daniel Roe's short video on the topic" videoId="0x1H6K5yOfs"}
68
68
 
@@ -63,7 +63,7 @@ We currently ship an environment for unit testing code that needs a [Nuxt](https
63
63
 
64
64
  ::tip
65
65
  When importing `@nuxt/test-utils` in your vitest config, It is necessary to have `"type": "module"` specified in your `package.json` or rename your vitest config file appropriately.
66
- > ie. `vitest.config.m{ts,js}`.
66
+ > i.e., `vitest.config.m{ts,js}`.
67
67
  ::
68
68
 
69
69
  ::tip
@@ -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 &mdash; 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
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
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
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
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
 
@@ -179,6 +140,7 @@ layers/
179
140
  modules/
180
141
  node_modules/
181
142
  public/
143
+ shared/
182
144
  server/
183
145
  api/
184
146
  middleware/
@@ -303,6 +265,64 @@ export default defineNuxtConfig({
303
265
  })
304
266
  ```
305
267
 
268
+ ### Corrected Module Loading Order in Layers
269
+
270
+ 🚦 **Impact Level**: Minimal
271
+
272
+ #### What Changed
273
+
274
+ 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.
275
+
276
+ Now modules are loaded in the correct order:
277
+
278
+ 1. **Layer modules first** (in extend order - deeper layers first)
279
+ 2. **Project modules last** (highest priority)
280
+
281
+ This affects both:
282
+ * Modules defined in the `modules` array in `nuxt.config.ts`
283
+ * Auto-discovered modules from the `modules/` directory
284
+
285
+ #### Reasons for Change
286
+
287
+ This change ensures that:
288
+ * Extended layers have lower priority than the consuming project
289
+ * Module execution order matches the intuitive layer inheritance pattern
290
+ * Module configuration and hooks work as expected in multi-layer setups
291
+
292
+ #### Migration Steps
293
+
294
+ **Most projects will not need changes**, as this corrects the loading order to match expected behavior.
295
+
296
+ However, if your project was relying on the previous incorrect order, you may need to:
297
+
298
+ 1. **Review module dependencies**: Check if any modules depend on specific loading order
299
+ 2. **Adjust module configuration**: If modules were configured to work around the incorrect order
300
+ 3. **Test thoroughly**: Ensure all functionality works as expected with the corrected order
301
+
302
+ Example of the new correct order:
303
+ ```ts
304
+ // Layer: my-layer/nuxt.config.ts
305
+ export default defineNuxtConfig({
306
+ modules: ['layer-module-1', 'layer-module-2']
307
+ })
308
+
309
+ // Project: nuxt.config.ts
310
+ export default defineNuxtConfig({
311
+ extends: ['./my-layer'],
312
+ modules: ['project-module-1', 'project-module-2']
313
+ })
314
+
315
+ // Loading order (corrected):
316
+ // 1. layer-module-1
317
+ // 2. layer-module-2
318
+ // 3. project-module-1 (can override layer modules)
319
+ // 4. project-module-2 (can override layer modules)
320
+ ```
321
+
322
+ 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.
323
+
324
+ 👉 See [PR #31507](https://github.com/nuxt/nuxt/pull/31507) and [issue #25719](https://github.com/nuxt/nuxt/issues/25719) for more details.
325
+
306
326
  ### Deduplication of Route Metadata
307
327
 
308
328
  🚦 **Impact Level**: Minimal
@@ -411,7 +431,7 @@ export default defineNuxtPlugin({
411
431
  })
412
432
  ```
413
433
 
414
- While not required it's recommend to update any imports from `@unhead/vue` to `#imports` or `nuxt/app`.
434
+ While not required it's recommended to update any imports from `@unhead/vue` to `#imports` or `nuxt/app`.
415
435
 
416
436
  ```diff
417
437
  -import { useHead } from '@unhead/vue'
@@ -490,16 +510,6 @@ Update your custom `error.vue` to remove any additional parsing of `error.data`:
490
510
  </script>
491
511
  ```
492
512
 
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
513
  ### More Granular Inline Styles
504
514
 
505
515
  🚦 **Impact Level**: Moderate
@@ -697,21 +707,6 @@ If you provide a custom `default` value for `useAsyncData`, this will now be use
697
707
 
698
708
  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
709
 
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
710
  ### Alignment of `pending` value in `useAsyncData` and `useFetch`
716
711
 
717
712
  🚦 **Impact Level**: Medium
@@ -784,7 +779,7 @@ This change should generally improve the expected behavior, but if you were expe
784
779
  query: { id },
785
780
  immediate: false
786
781
  )
787
- + watch(id, execute, { once: true })
782
+ + watch(id, () => execute(), { once: true })
788
783
  ```
789
784
 
790
785
  To opt out of this behavior:
@@ -980,7 +975,41 @@ const importName = genSafeVariableName
980
975
  You can automate this step by running `npx codemod@latest nuxt/4/template-compilation-changes`
981
976
  ::
982
977
 
983
- ### TypeScript Configuration Changes
978
+ ### Default TypeScript Configuration Changes
979
+
980
+ 🚦 **Impact Level**: Minimal
981
+
982
+ #### What Changed
983
+
984
+ `compilerOptions.noUncheckedIndexedAccess` is now `true` instead of `false`.
985
+
986
+ #### Reasons for Change
987
+
988
+ This change is a follow up to a prior [3.12 config update](https://github.com/nuxt/nuxt/pull/27485) where we improved our defaults, mostly adhering to [TotalTypeScript's recommendations](https://www.totaltypescript.com/tsconfig-cheat-sheet).
989
+
990
+ #### Migration Steps
991
+
992
+ There are two approaches:
993
+
994
+ 1. Run a typecheck on your app and fix any new errors (recommended).
995
+
996
+ 2. Override the new default in your `nuxt.config.ts`:
997
+
998
+ <!-- @case-police-ignore tsConfig -->
999
+
1000
+ ```ts
1001
+ export default defineNuxtConfig({
1002
+ typescript: {
1003
+ tsConfig: {
1004
+ compilerOptions: {
1005
+ noUncheckedIndexedAccess: false
1006
+ }
1007
+ }
1008
+ }
1009
+ })
1010
+ ```
1011
+
1012
+ ### TypeScript Configuration Splitting
984
1013
 
985
1014
  🚦 **Impact Level**: Minimal
986
1015
 
@@ -1127,7 +1156,7 @@ export default defineNuxtConfig({
1127
1156
  })
1128
1157
  ```
1129
1158
 
1130
- ::read-more{to="https://nitro.build/config/#prerender"}
1159
+ ::read-more{to="https://nitro.build/config#prerender"}
1131
1160
  Read more about Nitro's prerender configuration options.
1132
1161
  ::
1133
1162
 
@@ -19,4 +19,7 @@ surround: false
19
19
  ::card{icon="i-lucide-book-open" title="Recipes" to="/docs/guide/recipes"}
20
20
  Find solutions to common problems and learn how to implement them in your Nuxt project.
21
21
  ::
22
+ ::card{icon="i-lucide-square-check" title="Best Practices" to="/docs/guide/best-practices"}
23
+ Learn about best practices when developing with Nuxt
24
+ ::
22
25
  ::
@@ -70,7 +70,7 @@ Out of the box, a traditional Vue.js application is rendered in the browser (or
70
70
 
71
71
  **Benefits of client-side rendering:**
72
72
  - **Development speed**: When working entirely on the client-side, we don't have to worry about the server compatibility of the code, for example, by using browser-only APIs like the `window` object.
73
- - **Cheaper:** Running a server adds a cost of infrastructure as you would need to run on a platform that supports JavaScript. We can host Client-only applications on any static server with HTML, CSS, and JavaScript files.
73
+ - **Cheaper:** Running a server adds a cost of infrastructure as you would need to run on a platform that supports JavaScript. We can host client-only applications on any static server with HTML, CSS, and JavaScript files.
74
74
  - **Offline:** Because code entirely runs in the browser, it can nicely keep working while the internet is unavailable.
75
75
 
76
76
  **Downsides of client-side rendering:**
@@ -79,7 +79,7 @@ const MyButton = resolveComponent('MyButton')
79
79
  ```
80
80
 
81
81
  ::important
82
- If you are using `resolveComponent` to handle dynamic components, make sure not to insert anything but the name of the component, which must be a literal string and not be or contain a variable. The string is statically analyzed at compilation step.
82
+ If you are using `resolveComponent` to handle dynamic components, make sure not to insert anything but the name of the component, which must be a literal string and not be or contain a variable. The string is statically analyzed at the compilation step.
83
83
  ::
84
84
 
85
85
  :video-accordion{title="Watch Daniel Roe's short video about resolveComponent()" videoId="4kq8E5IUM2U"}
@@ -377,7 +377,7 @@ Learn more about `<NuxtLink>` usage.
377
377
  Nuxt allows programmatic navigation through the `navigateTo()` utility method. Using this utility method, you will be able to programmatically navigate the user in your app. This is great for taking input from the user and navigating them dynamically throughout your application. In this example, we have a simple method called `navigate()` that gets called when the user submits a search form.
378
378
 
379
379
  ::note
380
- Ensure to always `await` on `navigateTo` or chain its result by returning from functions.
380
+ Make sure to always `await` on `navigateTo` or chain its result by returning from functions.
381
381
  ::
382
382
 
383
383
  ```vue twoslash
@@ -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
  ```