@nuxt/docs 3.19.2 → 3.20.0

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 (192) hide show
  1. package/1.getting-started/01.introduction.md +2 -2
  2. package/1.getting-started/02.installation.md +2 -1
  3. package/1.getting-started/03.configuration.md +29 -29
  4. package/1.getting-started/04.views.md +7 -7
  5. package/1.getting-started/05.assets.md +15 -9
  6. package/1.getting-started/06.styling.md +55 -45
  7. package/1.getting-started/07.routing.md +12 -12
  8. package/1.getting-started/08.seo-meta.md +55 -42
  9. package/1.getting-started/09.transitions.md +47 -42
  10. package/1.getting-started/10.data-fetching.md +90 -67
  11. package/1.getting-started/11.state-management.md +22 -15
  12. package/1.getting-started/12.error-handling.md +11 -9
  13. package/1.getting-started/13.server.md +3 -3
  14. package/1.getting-started/14.layers.md +21 -15
  15. package/1.getting-started/15.prerendering.md +28 -28
  16. package/1.getting-started/16.deployment.md +9 -9
  17. package/1.getting-started/17.testing.md +43 -43
  18. package/1.getting-started/18.upgrade.md +66 -61
  19. package/2.guide/0.index.md +3 -3
  20. package/2.guide/{2.directory-structure → 1.directory-structure}/.navigation.yml +1 -1
  21. package/2.guide/{2.directory-structure → 1.directory-structure}/0.nuxt.md +3 -3
  22. package/2.guide/{2.directory-structure → 1.directory-structure}/0.output.md +3 -3
  23. package/2.guide/{2.directory-structure → 1.directory-structure}/1.assets.md +3 -3
  24. package/2.guide/{2.directory-structure → 1.directory-structure}/1.components.md +41 -24
  25. package/2.guide/{2.directory-structure → 1.directory-structure}/1.composables.md +11 -11
  26. package/2.guide/{2.directory-structure → 1.directory-structure}/1.content.md +7 -4
  27. package/2.guide/{2.directory-structure → 1.directory-structure}/1.layouts.md +16 -12
  28. package/2.guide/{2.directory-structure → 1.directory-structure}/1.middleware.md +28 -22
  29. package/2.guide/{2.directory-structure → 1.directory-structure}/1.modules.md +6 -6
  30. package/2.guide/{2.directory-structure → 1.directory-structure}/1.node_modules.md +2 -2
  31. package/2.guide/{2.directory-structure → 1.directory-structure}/1.pages.md +33 -31
  32. package/2.guide/{2.directory-structure → 1.directory-structure}/1.plugins.md +25 -25
  33. package/2.guide/{2.directory-structure → 1.directory-structure}/1.public.md +2 -2
  34. package/2.guide/{2.directory-structure → 1.directory-structure}/1.server.md +34 -34
  35. package/2.guide/{2.directory-structure → 1.directory-structure}/1.shared.md +6 -6
  36. package/2.guide/{2.directory-structure → 1.directory-structure}/1.utils.md +5 -5
  37. package/2.guide/{2.directory-structure → 1.directory-structure}/2.env.md +5 -5
  38. package/2.guide/{2.directory-structure → 1.directory-structure}/2.gitignore.md +1 -1
  39. package/2.guide/{2.directory-structure → 1.directory-structure}/2.nuxtignore.md +4 -4
  40. package/2.guide/{2.directory-structure → 1.directory-structure}/2.nuxtrc.md +3 -3
  41. package/2.guide/{2.directory-structure → 1.directory-structure}/3.app-config.md +12 -12
  42. package/2.guide/{2.directory-structure → 1.directory-structure}/3.app.md +4 -4
  43. package/2.guide/{2.directory-structure → 1.directory-structure}/3.error.md +6 -6
  44. package/2.guide/{2.directory-structure → 1.directory-structure}/3.nuxt-config.md +2 -2
  45. package/2.guide/{2.directory-structure → 1.directory-structure}/3.package.md +1 -1
  46. package/2.guide/{2.directory-structure → 1.directory-structure}/3.tsconfig.md +3 -3
  47. package/2.guide/{1.concepts → 2.concepts}/1.auto-imports.md +18 -18
  48. package/2.guide/{1.concepts → 2.concepts}/10.nuxt-lifecycle.md +10 -10
  49. package/2.guide/{1.concepts → 2.concepts}/2.vuejs-development.md +9 -9
  50. package/2.guide/{1.concepts → 2.concepts}/3.rendering.md +21 -19
  51. package/2.guide/{1.concepts → 2.concepts}/4.server-engine.md +5 -5
  52. package/2.guide/{1.concepts → 2.concepts}/5.modules.md +4 -4
  53. package/2.guide/{1.concepts → 2.concepts}/7.esm.md +20 -14
  54. package/2.guide/{1.concepts → 2.concepts}/8.typescript.md +11 -11
  55. package/2.guide/3.going-further/1.events.md +2 -2
  56. package/2.guide/3.going-further/1.experimental-features.md +168 -80
  57. package/2.guide/3.going-further/1.features.md +15 -15
  58. package/2.guide/3.going-further/1.internals.md +25 -25
  59. package/2.guide/3.going-further/10.runtime-config.md +11 -11
  60. package/2.guide/3.going-further/2.hooks.md +11 -11
  61. package/2.guide/3.going-further/3.modules.md +119 -101
  62. package/2.guide/3.going-further/4.kit.md +5 -5
  63. package/2.guide/3.going-further/6.nuxt-app.md +5 -5
  64. package/2.guide/3.going-further/7.layers.md +75 -58
  65. package/2.guide/3.going-further/9.debugging.md +2 -2
  66. package/2.guide/4.recipes/1.custom-routing.md +31 -31
  67. package/2.guide/4.recipes/2.vite-plugin.md +45 -4
  68. package/2.guide/4.recipes/3.custom-usefetch.md +12 -12
  69. package/2.guide/4.recipes/4.sessions-and-authentication.md +34 -20
  70. package/2.guide/5.best-practices/hydration.md +4 -4
  71. package/2.guide/5.best-practices/performance.md +12 -12
  72. package/3.api/1.components/1.client-only.md +6 -3
  73. package/3.api/1.components/1.nuxt-client-fallback.md +9 -6
  74. package/3.api/1.components/10.nuxt-picture.md +1 -1
  75. package/3.api/1.components/11.teleports.md +4 -1
  76. package/3.api/1.components/12.nuxt-route-announcer.md +9 -9
  77. package/3.api/1.components/13.nuxt-time.md +49 -18
  78. package/3.api/1.components/2.nuxt-page.md +4 -4
  79. package/3.api/1.components/3.nuxt-layout.md +11 -6
  80. package/3.api/1.components/4.nuxt-link.md +40 -20
  81. package/3.api/1.components/5.nuxt-loading-indicator.md +2 -2
  82. package/3.api/1.components/6.nuxt-error-boundary.md +11 -9
  83. package/3.api/2.composables/on-prehydrate.md +2 -2
  84. package/3.api/2.composables/use-async-data.md +23 -19
  85. package/3.api/2.composables/use-cookie.md +28 -20
  86. package/3.api/2.composables/use-error.md +1 -1
  87. package/3.api/2.composables/use-fetch.md +59 -29
  88. package/3.api/2.composables/use-head-safe.md +7 -7
  89. package/3.api/2.composables/use-head.md +4 -4
  90. package/3.api/2.composables/use-hydration.md +6 -6
  91. package/3.api/2.composables/use-lazy-async-data.md +2 -2
  92. package/3.api/2.composables/use-lazy-fetch.md +2 -2
  93. package/3.api/2.composables/use-loading-indicator.md +12 -12
  94. package/3.api/2.composables/use-nuxt-app.md +19 -19
  95. package/3.api/2.composables/use-nuxt-data.md +8 -8
  96. package/3.api/2.composables/use-preview-mode.md +15 -18
  97. package/3.api/2.composables/use-request-event.md +1 -1
  98. package/3.api/2.composables/use-request-fetch.md +3 -3
  99. package/3.api/2.composables/use-request-header.md +1 -1
  100. package/3.api/2.composables/use-request-headers.md +4 -4
  101. package/3.api/2.composables/use-request-url.md +1 -1
  102. package/3.api/2.composables/use-response-header.md +9 -10
  103. package/3.api/2.composables/use-route-announcer.md +4 -4
  104. package/3.api/2.composables/use-route.md +1 -1
  105. package/3.api/2.composables/use-router.md +9 -7
  106. package/3.api/2.composables/use-runtime-config.md +6 -6
  107. package/3.api/2.composables/use-runtime-hook.md +2 -2
  108. package/3.api/2.composables/use-seo-meta.md +2 -2
  109. package/3.api/2.composables/use-server-seo-meta.md +4 -4
  110. package/3.api/2.composables/use-state.md +4 -4
  111. package/3.api/3.utils/$fetch.md +9 -7
  112. package/3.api/3.utils/abort-navigation.md +3 -3
  113. package/3.api/3.utils/add-route-middleware.md +5 -5
  114. package/3.api/3.utils/call-once.md +4 -4
  115. package/3.api/3.utils/clear-error.md +2 -2
  116. package/3.api/3.utils/clear-nuxt-data.md +3 -3
  117. package/3.api/3.utils/clear-nuxt-state.md +3 -3
  118. package/3.api/3.utils/create-error.md +1 -1
  119. package/3.api/3.utils/define-lazy-hydration-component.md +13 -13
  120. package/3.api/3.utils/define-nuxt-component.md +5 -5
  121. package/3.api/3.utils/define-nuxt-plugin.md +12 -12
  122. package/3.api/3.utils/define-nuxt-route-middleware.md +5 -5
  123. package/3.api/3.utils/define-page-meta.md +21 -21
  124. package/3.api/3.utils/define-route-rules.md +5 -5
  125. package/3.api/3.utils/navigate-to.md +10 -10
  126. package/3.api/3.utils/prefetch-components.md +1 -1
  127. package/3.api/3.utils/preload-components.md +1 -1
  128. package/3.api/3.utils/prerender-routes.md +3 -3
  129. package/3.api/3.utils/refresh-cookie.md +3 -3
  130. package/3.api/3.utils/refresh-nuxt-data.md +11 -6
  131. package/3.api/3.utils/reload-nuxt-app.md +2 -2
  132. package/3.api/3.utils/set-page-layout.md +1 -1
  133. package/3.api/3.utils/set-response-status.md +2 -2
  134. package/3.api/3.utils/show-error.md +4 -4
  135. package/3.api/3.utils/update-app-config.md +3 -2
  136. package/3.api/4.commands/add.md +1 -1
  137. package/3.api/4.commands/analyze.md +2 -1
  138. package/3.api/4.commands/build.md +2 -1
  139. package/3.api/4.commands/dev.md +5 -4
  140. package/3.api/4.commands/generate.md +2 -1
  141. package/3.api/4.commands/init.md +3 -2
  142. package/3.api/4.commands/module.md +4 -4
  143. package/3.api/4.commands/prepare.md +7 -2
  144. package/3.api/4.commands/preview.md +5 -4
  145. package/3.api/4.commands/test.md +40 -0
  146. package/3.api/4.commands/typecheck.md +4 -2
  147. package/3.api/4.commands/upgrade.md +3 -3
  148. package/3.api/5.kit/1.modules.md +123 -37
  149. package/3.api/5.kit/10.runtime-config.md +1 -1
  150. package/3.api/5.kit/10.templates.md +8 -6
  151. package/3.api/5.kit/11.nitro.md +66 -62
  152. package/3.api/5.kit/12.resolving.md +2 -2
  153. package/3.api/5.kit/14.builder.md +61 -4
  154. package/3.api/5.kit/15.examples.md +5 -7
  155. package/3.api/5.kit/16.layers.md +26 -26
  156. package/3.api/5.kit/3.compatibility.md +12 -12
  157. package/3.api/5.kit/4.autoimports.md +13 -13
  158. package/3.api/5.kit/5.components.md +8 -7
  159. package/3.api/5.kit/6.context.md +3 -3
  160. package/3.api/5.kit/7.pages.md +7 -7
  161. package/3.api/5.kit/8.layout.md +2 -2
  162. package/3.api/5.kit/9.head.md +132 -0
  163. package/3.api/5.kit/9.plugins.md +6 -5
  164. package/3.api/6.advanced/1.hooks.md +4 -4
  165. package/3.api/6.advanced/2.import-meta.md +3 -3
  166. package/5.community/2.getting-help.md +1 -1
  167. package/5.community/3.reporting-bugs.md +1 -1
  168. package/5.community/4.contribution.md +6 -6
  169. package/5.community/5.framework-contribution.md +3 -3
  170. package/5.community/6.roadmap.md +1 -1
  171. package/6.bridge/1.overview.md +13 -13
  172. package/6.bridge/10.configuration.md +2 -1
  173. package/6.bridge/2.typescript.md +2 -2
  174. package/6.bridge/3.bridge-composition-api.md +6 -6
  175. package/6.bridge/4.plugins-and-middleware.md +9 -9
  176. package/6.bridge/5.nuxt3-compatible-api.md +19 -16
  177. package/6.bridge/6.meta.md +20 -19
  178. package/6.bridge/7.runtime-config.md +1 -1
  179. package/6.bridge/8.nitro.md +3 -3
  180. package/6.bridge/9.vite.md +4 -4
  181. package/7.migration/1.overview.md +2 -2
  182. package/7.migration/2.configuration.md +22 -20
  183. package/7.migration/20.module-authors.md +6 -6
  184. package/7.migration/3.auto-imports.md +3 -3
  185. package/7.migration/4.meta.md +20 -17
  186. package/7.migration/5.plugins-and-middleware.md +5 -5
  187. package/7.migration/6.pages-and-layouts.md +23 -19
  188. package/7.migration/7.component-options.md +14 -14
  189. package/7.migration/8.runtime-config.md +6 -6
  190. package/package.json +1 -1
  191. /package/2.guide/{1.concepts → 2.concepts}/.navigation.yml +0 -0
  192. /package/2.guide/{1.concepts → 2.concepts}/9.code-style.md +0 -0
@@ -32,7 +32,7 @@ bun x nuxt upgrade
32
32
 
33
33
  ### Nightly Release Channel
34
34
 
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.
35
+ To use the latest Nuxt build and test features before their release, read about the [nightly release channel](/docs/3.x/guide/going-further/nightly-release-channel) guide.
36
36
 
37
37
  ::warning
38
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"`.
@@ -120,19 +120,23 @@ You can run all the codemods mentioned in this guide using the following `codemo
120
120
  ::code-group
121
121
 
122
122
  ```bash [npm]
123
- npx codemod@latest nuxt/4/migration-recipe
123
+ # Using pinned version due to https://github.com/codemod-com/codemod/issues/1710
124
+ npx codemod@0.18.7 nuxt/4/migration-recipe
124
125
  ```
125
126
 
126
127
  ```bash [yarn]
127
- yarn dlx codemod@latest nuxt/4/migration-recipe
128
+ # Using pinned version due to https://github.com/codemod-com/codemod/issues/1710
129
+ yarn dlx codemod@0.18.7 nuxt/4/migration-recipe
128
130
  ```
129
131
 
130
132
  ```bash [pnpm]
131
- pnpm dlx codemod@latest nuxt/4/migration-recipe
133
+ # Using pinned version due to https://github.com/codemod-com/codemod/issues/1710
134
+ pnpm dlx codemod@0.18.7 nuxt/4/migration-recipe
132
135
  ```
133
136
 
134
137
  ```bash [bun]
135
- bun x codemod@latest nuxt/4/migration-recipe
138
+ # Using pinned version due to https://github.com/codemod-com/codemod/issues/1710
139
+ bun x codemod@0.18.7 nuxt/4/migration-recipe
136
140
  ```
137
141
 
138
142
  ::
@@ -221,8 +225,8 @@ export default defineNuxtConfig({
221
225
  srcDir: '.',
222
226
  // This specifies the directory prefix for `app/router.options.ts` and `app/spa-loading-template.html`
223
227
  dir: {
224
- app: 'app'
225
- }
228
+ app: 'app',
229
+ },
226
230
  })
227
231
  ```
228
232
 
@@ -259,14 +263,14 @@ These changes have been made to improve memory usage and increase consistency wi
259
263
  It may be beneficial to extract any calls to `useAsyncData` that share an explicit key (and have custom options) into their own composable:
260
264
 
261
265
  ```ts [composables/useUserData.ts]
262
- export function useUserData(userId: string) {
266
+ export function useUserData (userId: string) {
263
267
  return useAsyncData(
264
268
  `user-${userId}`,
265
269
  () => fetchUser(userId),
266
- {
270
+ {
267
271
  deep: true,
268
- transform: (user) => ({ ...user, lastAccessed: new Date() })
269
- }
272
+ transform: user => ({ ...user, lastAccessed: new Date() }),
273
+ },
270
274
  )
271
275
  }
272
276
  ```
@@ -295,8 +299,8 @@ Alternatively, for now, you can disable this behaviour with:
295
299
  export default defineNuxtConfig({
296
300
  experimental: {
297
301
  granularCachedData: false,
298
- purgeCachedData: false
299
- }
302
+ purgeCachedData: false,
303
+ },
300
304
  })
301
305
  ```
302
306
 
@@ -306,7 +310,7 @@ export default defineNuxtConfig({
306
310
 
307
311
  #### What Changed
308
312
 
309
- 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.
313
+ The order in which modules are loaded when using [Nuxt layers](/docs/3.x/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.
310
314
 
311
315
  Now modules are loaded in the correct order:
312
316
 
@@ -338,23 +342,23 @@ Example of the new correct order:
338
342
  ```ts
339
343
  // Layer: my-layer/nuxt.config.ts
340
344
  export default defineNuxtConfig({
341
- modules: ['layer-module-1', 'layer-module-2']
345
+ modules: ['layer-module-1', 'layer-module-2'],
342
346
  })
343
347
 
344
348
  // Project: nuxt.config.ts
345
349
  export default defineNuxtConfig({
346
350
  extends: ['./my-layer'],
347
- modules: ['project-module-1', 'project-module-2']
351
+ modules: ['project-module-1', 'project-module-2'],
348
352
  })
349
353
 
350
354
  // Loading order (corrected):
351
355
  // 1. layer-module-1
352
- // 2. layer-module-2
356
+ // 2. layer-module-2
353
357
  // 3. project-module-1 (can override layer modules)
354
358
  // 4. project-module-2 (can override layer modules)
355
359
  ```
356
360
 
357
- 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.
361
+ If you encounter issues with module order dependencies due to needing to register a hook, consider using the [`modules:done` hook](/docs/3.x/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.
358
362
 
359
363
  👉 See [PR #31507](https://github.com/nuxt/nuxt/pull/31507) and [issue #25719](https://github.com/nuxt/nuxt/issues/25719) for more details.
360
364
 
@@ -415,8 +419,8 @@ Alternatively, for now, you can disable this behaviour with:
415
419
  ```ts twoslash [nuxt.config.ts]
416
420
  export default defineNuxtConfig({
417
421
  experimental: {
418
- normalizeComponentNames: false
419
- }
422
+ normalizeComponentNames: false,
423
+ },
420
424
  })
421
425
  ```
422
426
 
@@ -455,14 +459,14 @@ useHead({
455
459
  * If you're using [Template Params](https://unhead.unjs.io/docs/head/guides/plugins/template-params) or [Alias Tag Sorting](https://unhead.unjs.io/docs/head/guides/plugins/alias-sorting), you will need to explicitly opt in to these features now.
456
460
 
457
461
  ```ts
458
- import { TemplateParamsPlugin, AliasSortingPlugin } from '@unhead/vue/plugins'
462
+ import { AliasSortingPlugin, TemplateParamsPlugin } from '@unhead/vue/plugins'
459
463
 
460
464
  export default defineNuxtPlugin({
461
- setup() {
465
+ setup () {
462
466
  const unhead = injectHead()
463
467
  unhead.use(TemplateParamsPlugin)
464
468
  unhead.use(AliasSortingPlugin)
465
- }
469
+ },
466
470
  })
467
471
  ```
468
472
 
@@ -479,7 +483,7 @@ If you still have issues you may revert to the v1 behavior by enabling the `head
479
483
  export default defineNuxtConfig({
480
484
  unhead: {
481
485
  legacy: true,
482
- }
486
+ },
483
487
  })
484
488
  ```
485
489
 
@@ -518,7 +522,7 @@ Alternatively, you can revert to the previous behaviour with:
518
522
  export default defineNuxtConfig({
519
523
  experimental: {
520
524
  spaLoadingTemplateLocation: 'within',
521
- }
525
+ },
522
526
  })
523
527
  ```
524
528
 
@@ -550,7 +554,7 @@ Alternatively, you can disable this change:
550
554
  ```ts twoslash [nuxt.config.ts]
551
555
  export default defineNuxtConfig({
552
556
  experimental: {
553
- parseErrorData: false
557
+ parseErrorData: false,
554
558
  },
555
559
  })
556
560
  ```
@@ -572,8 +576,8 @@ This feature is fully configurable and you can revert to the previous behavior b
572
576
  ```ts twoslash [nuxt.config.ts]
573
577
  export default defineNuxtConfig({
574
578
  features: {
575
- inlineStyles: true
576
- }
579
+ inlineStyles: true,
580
+ },
577
581
  })
578
582
  ```
579
583
 
@@ -611,8 +615,8 @@ Alternatively, you can revert to the previous behaviour with:
611
615
  ```ts twoslash [nuxt.config.ts]
612
616
  export default defineNuxtConfig({
613
617
  experimental: {
614
- scanPageMeta: true
615
- }
618
+ scanPageMeta: true,
619
+ },
616
620
  })
617
621
  ```
618
622
 
@@ -652,8 +656,8 @@ Alternatively, you can disable this feature with:
652
656
  ```ts twoslash [nuxt.config.ts]
653
657
  export default defineNuxtConfig({
654
658
  experimental: {
655
- sharedPrerenderData: false
656
- }
659
+ sharedPrerenderData: false,
660
+ },
657
661
  })
658
662
  ```
659
663
 
@@ -685,10 +689,10 @@ export default defineNuxtConfig({
685
689
  defaults: {
686
690
  useAsyncData: {
687
691
  value: 'null',
688
- errorValue: 'null'
689
- }
690
- }
691
- }
692
+ errorValue: 'null',
693
+ },
694
+ },
695
+ },
692
696
  })
693
697
  ```
694
698
 
@@ -703,7 +707,8 @@ Please report an issue if you are doing this, as we do not plan to keep this as
703
707
  Previously it was possible to pass `dedupe: boolean` to `refresh`. These were aliases of `cancel` (`true`) and `defer` (`false`).
704
708
 
705
709
  ```ts twoslash [app.vue]
706
- const { refresh } = await useAsyncData(async () => ({ message: 'Hello, Nuxt!' }))
710
+ // @errors: 2322
711
+ const { refresh } = await useAsyncData(() => Promise.resolve({ message: 'Hello, Nuxt!' }))
707
712
 
708
713
  async function refreshData () {
709
714
  await refresh({ dedupe: true })
@@ -758,7 +763,7 @@ If you encounter any issues you can revert back to the previous behavior, for no
758
763
  export default defineNuxtConfig({
759
764
  experimental: {
760
765
  resetAsyncDataToUndefined: true,
761
- }
766
+ },
762
767
  })
763
768
  ```
764
769
 
@@ -805,8 +810,8 @@ Alternatively, you can temporarily revert to the previous behavior with:
805
810
  ```ts twoslash [nuxt.config.ts]
806
811
  export default defineNuxtConfig({
807
812
  experimental: {
808
- pendingWhenIdle: true
809
- }
813
+ pendingWhenIdle: true,
814
+ },
810
815
  })
811
816
  ```
812
817
 
@@ -845,8 +850,8 @@ To opt out of this behavior:
845
850
  // Or globally in your Nuxt config
846
851
  export default defineNuxtConfig({
847
852
  experimental: {
848
- alwaysRunFetchOnKeyChange: true
849
- }
853
+ alwaysRunFetchOnKeyChange: true,
854
+ },
850
855
  })
851
856
  ```
852
857
 
@@ -879,10 +884,10 @@ In most cases, no migration steps are required, but if you rely on the reactivit
879
884
  experimental: {
880
885
  defaults: {
881
886
  useAsyncData: {
882
- deep: true
883
- }
884
- }
885
- }
887
+ deep: true,
888
+ },
889
+ },
890
+ },
886
891
  })
887
892
  ```
888
893
 
@@ -961,10 +966,10 @@ Probably no migration is necessary but if you wish to revert to previous behavio
961
966
  ```ts
962
967
  export default defineNuxtConfig({
963
968
  hooks: {
964
- 'app:resolve'(app) {
969
+ 'app:resolve' (app) {
965
970
  app.middleware = app.middleware.filter(mw => !/\/index\.[^/]+$/.test(mw.path))
966
- }
967
- }
971
+ },
972
+ },
968
973
  })
969
974
  ```
970
975
 
@@ -1014,7 +1019,7 @@ Finally, if you are using the template utilities (`serialize`, `importName`, `im
1014
1019
  ```ts
1015
1020
  import { genDynamicImport, genImport, genSafeVariableName } from 'knitwork'
1016
1021
 
1017
- const serialize = (data: any) => JSON.stringify(data, null, 2).replace(/"{(.+)}"(?=,?$)/gm, r => JSON.parse(r).replace(/^{(.*)}$/, '$1'))
1022
+ const serialize = (data: any) => JSON.stringify(data, null, 2).replace(/"\{(.+)\}"(?=,?$)/gm, r => JSON.parse(r).replace(/^\{(.*)\}$/, '$1'))
1018
1023
 
1019
1024
  const importSources = (sources: string | string[], { lazy = false } = {}) => {
1020
1025
  return toArray(sources).map((src) => {
@@ -1059,10 +1064,10 @@ There are two approaches:
1059
1064
  typescript: {
1060
1065
  tsConfig: {
1061
1066
  compilerOptions: {
1062
- noUncheckedIndexedAccess: false
1063
- }
1064
- }
1065
- }
1067
+ noUncheckedIndexedAccess: false,
1068
+ },
1069
+ },
1070
+ },
1066
1071
  })
1067
1072
  ```
1068
1073
 
@@ -1147,16 +1152,16 @@ However, to take advantage of improved type checking, you can opt in to the new
1147
1152
  // Customize app/server TypeScript config
1148
1153
  tsConfig: {
1149
1154
  compilerOptions: {
1150
- strict: true
1151
- }
1155
+ strict: true,
1156
+ },
1152
1157
  },
1153
- // Customize build-time TypeScript config
1158
+ // Customize build-time TypeScript config
1154
1159
  nodeTsConfig: {
1155
1160
  compilerOptions: {
1156
- strict: true
1157
- }
1158
- }
1159
- }
1161
+ strict: true,
1162
+ },
1163
+ },
1164
+ },
1160
1165
  })
1161
1166
  ```
1162
1167
 
@@ -7,12 +7,12 @@ surround: false
7
7
  ---
8
8
 
9
9
  ::card-group{class="sm:grid-cols-1"}
10
- ::card{icon="i-lucide-medal" title="Key Concepts" to="/docs/guide/concepts"}
11
- Discover the main concepts behind Nuxt, from auto-import, hybrid rendering to its TypeScript support.
12
- ::
13
10
  ::card{icon="i-lucide-folders" title="Directory Structure" to="/docs/guide/directory-structure"}
14
11
  Learn about Nuxt directory structure and what benefits each directory or file offers.
15
12
  ::
13
+ ::card{icon="i-lucide-medal" title="Key Concepts" to="/docs/guide/concepts"}
14
+ Discover the main concepts behind Nuxt, from auto-import, hybrid rendering to its TypeScript support.
15
+ ::
16
16
  ::card{icon="i-lucide-star" title="Going Further" to="/docs/guide/going-further"}
17
17
  Master Nuxt with advanced concepts like experimental features, hooks, modules, and more.
18
18
  ::
@@ -1,3 +1,3 @@
1
1
  title: Directory Structure
2
2
  titleTemplate: '%s · Nuxt Directory Structure'
3
- icon: i-lucide-folders
3
+ icon: i-vscode-icons-default-folder
@@ -2,11 +2,11 @@
2
2
  title: ".nuxt"
3
3
  description: "Nuxt uses the .nuxt/ directory in development to generate your Vue application."
4
4
  head.title: ".nuxt/"
5
- navigation.icon: i-lucide-folder
5
+ navigation.icon: i-vscode-icons-folder-type-temp
6
6
  ---
7
7
 
8
8
  ::important
9
- This directory should be added to your [`.gitignore`](/docs/guide/directory-structure/gitignore) file to avoid pushing the dev build output to your repository.
9
+ This directory should be added to your [`.gitignore`](/docs/3.x/guide/directory-structure/gitignore) file to avoid pushing the dev build output to your repository.
10
10
  ::
11
11
 
12
12
  This directory is interesting if you want to learn more about the files Nuxt generates based on your directory structure.
@@ -16,5 +16,5 @@ Nuxt also provides a Virtual File System (VFS) for modules to add templates to t
16
16
  You can explore the generated files by opening the [Nuxt DevTools](https://devtools.nuxt.com) in development mode and navigating to the **Virtual Files** tab.
17
17
 
18
18
  ::warning
19
- You should not touch any files inside since the whole directory will be re-created when running [`nuxt dev`](/docs/api/commands/dev).
19
+ You should not touch any files inside since the whole directory will be re-created when running [`nuxt dev`](/docs/3.x/api/commands/dev).
20
20
  ::
@@ -2,11 +2,11 @@
2
2
  title: ".output"
3
3
  description: "Nuxt creates the .output/ directory when building your application for production."
4
4
  head.title: ".output/"
5
- navigation.icon: i-lucide-folder
5
+ navigation.icon: i-vscode-icons-folder-type-package
6
6
  ---
7
7
 
8
8
  ::important
9
- This directory should be added to your [`.gitignore`](/docs/guide/directory-structure/gitignore) file to avoid pushing the build output to your repository.
9
+ This directory should be added to your [`.gitignore`](/docs/3.x/guide/directory-structure/gitignore) file to avoid pushing the build output to your repository.
10
10
  ::
11
11
 
12
12
  Use this directory to deploy your Nuxt application to production.
@@ -14,5 +14,5 @@ Use this directory to deploy your Nuxt application to production.
14
14
  :read-more{to="/docs/getting-started/deployment"}
15
15
 
16
16
  ::warning
17
- You should not touch any files inside since the whole directory will be re-created when running [`nuxt build`](/docs/api/commands/build).
17
+ You should not touch any files inside since the whole directory will be re-created when running [`nuxt build`](/docs/3.x/api/commands/build).
18
18
  ::
@@ -2,15 +2,15 @@
2
2
  title: "assets"
3
3
  description: "The assets/ directory is used to add all the website's assets that the build tool will process."
4
4
  head.title: "assets/"
5
- navigation.icon: i-lucide-folder
5
+ navigation.icon: i-vscode-icons-folder-type-asset
6
6
  ---
7
7
 
8
8
  The directory usually contains the following types of files:
9
9
 
10
10
  - Stylesheets (CSS, SASS, etc.)
11
11
  - Fonts
12
- - Images that won't be served from the [`public/`](/docs/guide/directory-structure/public) directory.
12
+ - Images that won't be served from the [`public/`](/docs/3.x/guide/directory-structure/public) directory.
13
13
 
14
- If you want to serve assets from the server, we recommend taking a look at the [`public/`](/docs/guide/directory-structure/public) directory.
14
+ If you want to serve assets from the server, we recommend taking a look at the [`public/`](/docs/3.x/guide/directory-structure/public) directory.
15
15
 
16
16
  :read-more{to="/docs/getting-started/assets"}
@@ -2,7 +2,7 @@
2
2
  title: "components"
3
3
  head.title: "components/"
4
4
  description: "The components/ directory is where you put all your Vue components."
5
- navigation.icon: i-lucide-folder
5
+ navigation.icon: i-vscode-icons-folder-type-component
6
6
  ---
7
7
 
8
8
  Nuxt automatically imports any components in this directory (along with components that are registered by any modules you may be using).
@@ -54,7 +54,7 @@ export default defineNuxtConfig({
54
54
  pathPrefix: false, // [!code ++]
55
55
  },
56
56
  ],
57
- });
57
+ })
58
58
  ```
59
59
 
60
60
  This registers the components using the same strategy as used in Nuxt 2. For example, `~/components/Some/MyComponent.vue` will be usable as `<MyComponent>` and not `<SomeMyComponent>`.
@@ -116,7 +116,12 @@ const show = ref(false)
116
116
  <div>
117
117
  <h1>Mountains</h1>
118
118
  <LazyMountainsList v-if="show" />
119
- <button v-if="!show" @click="show = true">Show List</button>
119
+ <button
120
+ v-if="!show"
121
+ @click="show = true"
122
+ >
123
+ Show List
124
+ </button>
120
125
  </div>
121
126
  </template>
122
127
  ```
@@ -235,9 +240,10 @@ Hydrates the component based on a boolean condition.
235
240
  <LazyMyComponent :hydrate-when="isReady" />
236
241
  </div>
237
242
  </template>
243
+
238
244
  <script setup lang="ts">
239
245
  const isReady = ref(false)
240
- function myFunction() {
246
+ function myFunction () {
241
247
  // trigger custom hydration strategy...
242
248
  isReady.value = true
243
249
  }
@@ -263,13 +269,16 @@ All delayed hydration components emit a `@hydrated` event when they are hydrated
263
269
  ```vue [pages/index.vue]
264
270
  <template>
265
271
  <div>
266
- <LazyMyComponent hydrate-on-visible @hydrated="onHydrate" />
272
+ <LazyMyComponent
273
+ hydrate-on-visible
274
+ @hydrated="onHydrate"
275
+ />
267
276
  </div>
268
277
  </template>
269
278
 
270
279
  <script setup lang="ts">
271
- function onHydrate() {
272
- console.log("Component has been hydrated!")
280
+ function onHydrate () {
281
+ console.log('Component has been hydrated!')
273
282
  }
274
283
  </script>
275
284
  ```
@@ -297,7 +306,7 @@ You can also explicitly import components from `#components` if you want or need
297
306
 
298
307
  ```vue [pages/index.vue]
299
308
  <script setup lang="ts">
300
- import { NuxtLink, LazyMountainsList } from '#components'
309
+ import { LazyMountainsList, NuxtLink } from '#components'
301
310
 
302
311
  const show = ref(false)
303
312
  </script>
@@ -306,7 +315,12 @@ const show = ref(false)
306
315
  <div>
307
316
  <h1>Mountains</h1>
308
317
  <LazyMountainsList v-if="show" />
309
- <button v-if="!show" @click="show = true">Show List</button>
318
+ <button
319
+ v-if="!show"
320
+ @click="show = true"
321
+ >
322
+ Show List
323
+ </button>
310
324
  <NuxtLink to="/">Home</NuxtLink>
311
325
  </div>
312
326
  </template>
@@ -333,8 +347,8 @@ export default defineNuxtConfig({
333
347
  //
334
348
  // ~/components/Btn.vue => <Btn />
335
349
  // ~/components/base/Btn.vue => <BaseBtn />
336
- '~/components'
337
- ]
350
+ '~/components',
351
+ ],
338
352
  })
339
353
  ```
340
354
 
@@ -344,7 +358,7 @@ Any nested directories need to be added first as they are scanned in order.
344
358
 
345
359
  ## npm Packages
346
360
 
347
- If you want to auto-import components from an npm package, you can use [`addComponent`](/docs/api/kit/components#addcomponent) in a [local module](/docs/guide/directory-structure/modules) to register them.
361
+ If you want to auto-import components from an npm package, you can use [`addComponent`](/docs/3.x/api/kit/components#addcomponent) in a [local module](/docs/3.x/guide/directory-structure/modules) to register them.
348
362
 
349
363
  ::code-group
350
364
 
@@ -352,7 +366,7 @@ If you want to auto-import components from an npm package, you can use [`addComp
352
366
  import { addComponent, defineNuxtModule } from '@nuxt/kit'
353
367
 
354
368
  export default defineNuxtModule({
355
- setup() {
369
+ setup () {
356
370
  // import { MyComponent as MyAutoImportedComponent } from 'my-npm-package'
357
371
  addComponent({
358
372
  name: 'MyAutoImportedComponent',
@@ -376,7 +390,7 @@ export default defineNuxtModule({
376
390
 
377
391
  ## Component Extensions
378
392
 
379
- By default, any file with an extension specified in the [extensions key of `nuxt.config.ts`](/docs/api/nuxt-config#extensions) is treated as a component.
393
+ By default, any file with an extension specified in the [extensions key of `nuxt.config.ts`](/docs/3.x/api/nuxt-config#extensions) is treated as a component.
380
394
  If you need to restrict the file extensions that should be registered as components, you can use the extended form of the components directory declaration and its `extensions` key:
381
395
 
382
396
  ```ts twoslash [nuxt.config.ts]
@@ -385,8 +399,8 @@ export default defineNuxtConfig({
385
399
  {
386
400
  path: '~/components',
387
401
  extensions: ['.vue'], // [!code ++]
388
- }
389
- ]
402
+ },
403
+ ],
390
404
  })
391
405
  ```
392
406
 
@@ -443,8 +457,8 @@ Server components are currently experimental and in order to use them, you need
443
457
  ```ts twoslash [nuxt.config.ts]
444
458
  export default defineNuxtConfig({
445
459
  experimental: {
446
- componentIslands: true
447
- }
460
+ componentIslands: true,
461
+ },
448
462
  })
449
463
  ```
450
464
 
@@ -467,7 +481,7 @@ Now you can register server-only components with the `.server` suffix and use th
467
481
  </template>
468
482
  ```
469
483
 
470
- Server-only components use [`<NuxtIsland>`](/docs/api/components/nuxt-island) under the hood, meaning that `lazy` prop and `#fallback` slot are both passed down to it.
484
+ Server-only components use [`<NuxtIsland>`](/docs/3.x/api/components/nuxt-island) under the hood, meaning that `lazy` prop and `#fallback` slot are both passed down to it.
471
485
 
472
486
  ::warning
473
487
  Server components (and islands) must have a single root element. (HTML comments are considered elements as well.)
@@ -498,7 +512,10 @@ You can partially hydrate a component by setting a `nuxt-client` attribute on th
498
512
  <div>
499
513
  <HighlightedMarkdown markdown="# Headline" />
500
514
  <!-- Counter will be loaded and hydrated client-side -->
501
- <Counter nuxt-client :count="5" />
515
+ <Counter
516
+ nuxt-client
517
+ :count="5"
518
+ />
502
519
  </div>
503
520
  </template>
504
521
  ```
@@ -554,7 +571,7 @@ There are a number of components that Nuxt provides, including `<ClientOnly>` an
554
571
 
555
572
  Making Vue component libraries with automatic tree-shaking and component registration is super easy. ✨
556
573
 
557
- You can use the [`addComponentsDir`](/docs/api/kit/components#addcomponentsdir) method provided from the `@nuxt/kit` to register your components directory in your Nuxt module.
574
+ You can use the [`addComponentsDir`](/docs/3.x/api/kit/components#addcomponentsdir) method provided from the `@nuxt/kit` to register your components directory in your Nuxt module.
558
575
 
559
576
  Imagine a directory structure like this:
560
577
 
@@ -573,10 +590,10 @@ Imagine a directory structure like this:
573
590
  Then in `awesome-ui/nuxt.ts` you can use the `addComponentsDir` hook:
574
591
 
575
592
  ```ts twoslash
576
- import { createResolver, defineNuxtModule, addComponentsDir } from '@nuxt/kit'
593
+ import { addComponentsDir, createResolver, defineNuxtModule } from '@nuxt/kit'
577
594
 
578
595
  export default defineNuxtModule({
579
- setup() {
596
+ setup () {
580
597
  const resolver = createResolver(import.meta.url)
581
598
 
582
599
  // Add ./components dir to the list
@@ -592,7 +609,7 @@ That's it! Now in your project, you can import your UI library as a Nuxt module
592
609
 
593
610
  ```ts twoslash [nuxt.config.ts]
594
611
  export default defineNuxtConfig({
595
- modules: ['awesome-ui/nuxt']
612
+ modules: ['awesome-ui/nuxt'],
596
613
  })
597
614
  ```
598
615