@nuxt/docs 4.1.1 → 4.1.3

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 (200) hide show
  1. package/1.getting-started/01.introduction.md +6 -6
  2. package/1.getting-started/02.installation.md +2 -1
  3. package/1.getting-started/03.configuration.md +37 -37
  4. package/1.getting-started/04.views.md +9 -9
  5. package/1.getting-started/05.assets.md +15 -9
  6. package/1.getting-started/06.styling.md +58 -48
  7. package/1.getting-started/07.routing.md +17 -17
  8. package/1.getting-started/08.seo-meta.md +59 -46
  9. package/1.getting-started/09.transitions.md +49 -44
  10. package/1.getting-started/10.data-fetching.md +104 -81
  11. package/1.getting-started/11.state-management.md +27 -20
  12. package/1.getting-started/12.error-handling.md +22 -20
  13. package/1.getting-started/13.server.md +8 -8
  14. package/1.getting-started/14.layers.md +22 -16
  15. package/1.getting-started/15.prerendering.md +32 -32
  16. package/1.getting-started/16.deployment.md +10 -10
  17. package/1.getting-started/17.testing.md +44 -44
  18. package/1.getting-started/18.upgrade.md +53 -71
  19. package/2.guide/0.index.md +7 -7
  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/1.directory-structure/0.output.md +18 -0
  23. package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/.navigation.yml +1 -1
  24. package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.assets.md +4 -4
  25. package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.components.md +49 -28
  26. package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.composables.md +13 -13
  27. package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.layouts.md +19 -15
  28. package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.middleware.md +31 -25
  29. package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.pages.md +39 -37
  30. package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.plugins.md +25 -25
  31. package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.utils.md +7 -7
  32. package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/3.app-config.md +18 -18
  33. package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/3.app.md +7 -7
  34. package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/3.error.md +6 -6
  35. package/2.guide/{2.directory-structure → 1.directory-structure}/1.content.md +7 -4
  36. package/2.guide/{2.directory-structure → 1.directory-structure}/1.modules.md +8 -8
  37. package/2.guide/{2.directory-structure → 1.directory-structure}/1.node_modules.md +2 -2
  38. package/2.guide/{2.directory-structure → 1.directory-structure}/1.public.md +2 -2
  39. package/2.guide/{2.directory-structure → 1.directory-structure}/1.server.md +35 -35
  40. package/2.guide/{2.directory-structure → 1.directory-structure}/1.shared.md +7 -7
  41. package/2.guide/{2.directory-structure → 1.directory-structure}/2.env.md +8 -8
  42. package/2.guide/{2.directory-structure → 1.directory-structure}/2.gitignore.md +1 -1
  43. package/2.guide/{2.directory-structure → 1.directory-structure}/2.nuxtignore.md +5 -4
  44. package/2.guide/{2.directory-structure → 1.directory-structure}/2.nuxtrc.md +4 -4
  45. package/2.guide/{2.directory-structure → 1.directory-structure}/3.nuxt-config.md +3 -3
  46. package/2.guide/{2.directory-structure → 1.directory-structure}/3.package.md +1 -1
  47. package/2.guide/{2.directory-structure → 1.directory-structure}/3.tsconfig.md +3 -3
  48. package/2.guide/{1.concepts → 2.concepts}/1.auto-imports.md +22 -22
  49. package/2.guide/{1.concepts → 2.concepts}/10.nuxt-lifecycle.md +17 -17
  50. package/2.guide/{1.concepts → 2.concepts}/2.vuejs-development.md +13 -13
  51. package/2.guide/{1.concepts → 2.concepts}/3.rendering.md +24 -22
  52. package/2.guide/{1.concepts → 2.concepts}/4.server-engine.md +6 -6
  53. package/2.guide/{1.concepts → 2.concepts}/5.modules.md +5 -5
  54. package/2.guide/{1.concepts → 2.concepts}/7.esm.md +17 -15
  55. package/2.guide/{1.concepts → 2.concepts}/8.typescript.md +12 -12
  56. package/2.guide/3.going-further/1.events.md +3 -3
  57. package/2.guide/3.going-further/1.experimental-features.md +246 -85
  58. package/2.guide/3.going-further/1.features.md +44 -9
  59. package/2.guide/3.going-further/1.internals.md +25 -25
  60. package/2.guide/3.going-further/10.runtime-config.md +12 -12
  61. package/2.guide/3.going-further/11.nightly-release-channel.md +1 -1
  62. package/2.guide/3.going-further/2.hooks.md +14 -14
  63. package/2.guide/3.going-further/3.modules.md +96 -94
  64. package/2.guide/3.going-further/4.kit.md +7 -7
  65. package/2.guide/3.going-further/6.nuxt-app.md +8 -8
  66. package/2.guide/3.going-further/7.layers.md +62 -53
  67. package/2.guide/3.going-further/9.debugging.md +2 -2
  68. package/2.guide/4.recipes/1.custom-routing.md +30 -30
  69. package/2.guide/4.recipes/2.vite-plugin.md +4 -4
  70. package/2.guide/4.recipes/3.custom-usefetch.md +13 -13
  71. package/2.guide/4.recipes/4.sessions-and-authentication.md +35 -21
  72. package/2.guide/5.best-practices/hydration.md +4 -4
  73. package/2.guide/5.best-practices/performance.md +17 -17
  74. package/3.api/1.components/1.client-only.md +6 -3
  75. package/3.api/1.components/1.nuxt-client-fallback.md +10 -7
  76. package/3.api/1.components/10.nuxt-picture.md +1 -1
  77. package/3.api/1.components/11.teleports.md +5 -2
  78. package/3.api/1.components/12.nuxt-route-announcer.md +9 -9
  79. package/3.api/1.components/13.nuxt-time.md +44 -17
  80. package/3.api/1.components/2.nuxt-page.md +6 -6
  81. package/3.api/1.components/3.nuxt-layout.md +15 -10
  82. package/3.api/1.components/4.nuxt-link.md +42 -22
  83. package/3.api/1.components/5.nuxt-loading-indicator.md +3 -3
  84. package/3.api/1.components/6.nuxt-error-boundary.md +12 -10
  85. package/3.api/2.composables/on-prehydrate.md +2 -2
  86. package/3.api/2.composables/use-app-config.md +1 -1
  87. package/3.api/2.composables/use-async-data.md +20 -20
  88. package/3.api/2.composables/use-cookie.md +29 -21
  89. package/3.api/2.composables/use-error.md +2 -2
  90. package/3.api/2.composables/use-fetch.md +58 -32
  91. package/3.api/2.composables/use-head-safe.md +7 -7
  92. package/3.api/2.composables/use-head.md +5 -5
  93. package/3.api/2.composables/use-hydration.md +6 -6
  94. package/3.api/2.composables/use-lazy-async-data.md +4 -4
  95. package/3.api/2.composables/use-lazy-fetch.md +4 -4
  96. package/3.api/2.composables/use-loading-indicator.md +12 -12
  97. package/3.api/2.composables/use-nuxt-app.md +22 -22
  98. package/3.api/2.composables/use-nuxt-data.md +8 -8
  99. package/3.api/2.composables/use-preview-mode.md +15 -18
  100. package/3.api/2.composables/use-request-event.md +1 -1
  101. package/3.api/2.composables/use-request-fetch.md +3 -3
  102. package/3.api/2.composables/use-request-header.md +1 -1
  103. package/3.api/2.composables/use-request-headers.md +4 -4
  104. package/3.api/2.composables/use-request-url.md +1 -1
  105. package/3.api/2.composables/use-response-header.md +9 -10
  106. package/3.api/2.composables/use-route-announcer.md +4 -4
  107. package/3.api/2.composables/use-route.md +1 -1
  108. package/3.api/2.composables/use-router.md +10 -8
  109. package/3.api/2.composables/use-runtime-config.md +11 -11
  110. package/3.api/2.composables/use-runtime-hook.md +2 -2
  111. package/3.api/2.composables/use-seo-meta.md +4 -4
  112. package/3.api/2.composables/use-server-seo-meta.md +6 -6
  113. package/3.api/2.composables/use-state.md +5 -5
  114. package/3.api/3.utils/$fetch.md +10 -8
  115. package/3.api/3.utils/abort-navigation.md +3 -3
  116. package/3.api/3.utils/add-route-middleware.md +5 -5
  117. package/3.api/3.utils/call-once.md +6 -6
  118. package/3.api/3.utils/clear-error.md +3 -3
  119. package/3.api/3.utils/clear-nuxt-data.md +3 -3
  120. package/3.api/3.utils/clear-nuxt-state.md +3 -3
  121. package/3.api/3.utils/create-error.md +2 -2
  122. package/3.api/3.utils/define-lazy-hydration-component.md +13 -13
  123. package/3.api/3.utils/define-nuxt-component.md +5 -5
  124. package/3.api/3.utils/define-nuxt-plugin.md +13 -13
  125. package/3.api/3.utils/define-nuxt-route-middleware.md +5 -5
  126. package/3.api/3.utils/define-page-meta.md +23 -23
  127. package/3.api/3.utils/define-route-rules.md +7 -7
  128. package/3.api/3.utils/navigate-to.md +11 -11
  129. package/3.api/3.utils/prefetch-components.md +1 -1
  130. package/3.api/3.utils/preload-components.md +1 -1
  131. package/3.api/3.utils/preload-route-components.md +2 -2
  132. package/3.api/3.utils/prerender-routes.md +3 -3
  133. package/3.api/3.utils/refresh-cookie.md +4 -4
  134. package/3.api/3.utils/refresh-nuxt-data.md +12 -7
  135. package/3.api/3.utils/reload-nuxt-app.md +3 -3
  136. package/3.api/3.utils/set-page-layout.md +1 -1
  137. package/3.api/3.utils/set-response-status.md +3 -3
  138. package/3.api/3.utils/show-error.md +5 -5
  139. package/3.api/3.utils/update-app-config.md +4 -3
  140. package/3.api/4.commands/add.md +1 -1
  141. package/3.api/4.commands/analyze.md +2 -1
  142. package/3.api/4.commands/build.md +2 -1
  143. package/3.api/4.commands/dev.md +5 -4
  144. package/3.api/4.commands/generate.md +3 -2
  145. package/3.api/4.commands/init.md +3 -2
  146. package/3.api/4.commands/module.md +4 -4
  147. package/3.api/4.commands/prepare.md +7 -2
  148. package/3.api/4.commands/preview.md +5 -4
  149. package/3.api/4.commands/test.md +40 -0
  150. package/3.api/4.commands/typecheck.md +5 -3
  151. package/3.api/4.commands/upgrade.md +3 -3
  152. package/3.api/5.kit/1.modules.md +36 -36
  153. package/3.api/5.kit/10.runtime-config.md +1 -1
  154. package/3.api/5.kit/10.templates.md +8 -6
  155. package/3.api/5.kit/11.nitro.md +62 -62
  156. package/3.api/5.kit/12.resolving.md +2 -2
  157. package/3.api/5.kit/14.builder.md +1 -0
  158. package/3.api/5.kit/15.examples.md +2 -2
  159. package/3.api/5.kit/16.layers.md +26 -26
  160. package/3.api/5.kit/3.compatibility.md +14 -14
  161. package/3.api/5.kit/4.autoimports.md +13 -13
  162. package/3.api/5.kit/5.components.md +7 -8
  163. package/3.api/5.kit/6.context.md +3 -3
  164. package/3.api/5.kit/7.pages.md +7 -7
  165. package/3.api/5.kit/8.layout.md +2 -2
  166. package/3.api/5.kit/9.plugins.md +5 -4
  167. package/3.api/6.advanced/1.hooks.md +3 -3
  168. package/3.api/6.advanced/2.import-meta.md +3 -3
  169. package/3.api/6.nuxt-config.md +300 -865
  170. package/3.api/index.md +7 -7
  171. package/5.community/2.getting-help.md +1 -1
  172. package/5.community/3.reporting-bugs.md +1 -1
  173. package/5.community/4.contribution.md +11 -11
  174. package/5.community/5.framework-contribution.md +4 -4
  175. package/5.community/6.roadmap.md +1 -1
  176. package/6.bridge/1.overview.md +13 -13
  177. package/6.bridge/10.configuration.md +2 -1
  178. package/6.bridge/2.typescript.md +3 -3
  179. package/6.bridge/3.bridge-composition-api.md +8 -8
  180. package/6.bridge/4.plugins-and-middleware.md +9 -9
  181. package/6.bridge/5.nuxt3-compatible-api.md +20 -17
  182. package/6.bridge/6.meta.md +21 -20
  183. package/6.bridge/7.runtime-config.md +1 -1
  184. package/6.bridge/8.nitro.md +3 -3
  185. package/6.bridge/9.vite.md +4 -4
  186. package/7.migration/1.overview.md +2 -2
  187. package/7.migration/10.bundling.md +1 -1
  188. package/7.migration/11.server.md +3 -3
  189. package/7.migration/2.configuration.md +23 -21
  190. package/7.migration/20.module-authors.md +7 -7
  191. package/7.migration/3.auto-imports.md +3 -3
  192. package/7.migration/4.meta.md +21 -18
  193. package/7.migration/5.plugins-and-middleware.md +8 -8
  194. package/7.migration/6.pages-and-layouts.md +28 -24
  195. package/7.migration/7.component-options.md +18 -18
  196. package/7.migration/8.runtime-config.md +7 -7
  197. package/package.json +1 -1
  198. package/2.guide/2.directory-structure/0.output.md +0 -18
  199. /package/2.guide/{1.concepts → 2.concepts}/.navigation.yml +0 -0
  200. /package/2.guide/{1.concepts → 2.concepts}/9.code-style.md +0 -0
@@ -5,7 +5,7 @@ navigation.icon: i-lucide-circle-check
5
5
  ---
6
6
 
7
7
  ::tip
8
- If you are a module author, you can find more specific information in the [Module Author's guide](/docs/guide/going-further/modules#testing).
8
+ If you are a module author, you can find more specific information in the [Module Author's guide](/docs/4.x/guide/going-further/modules#testing).
9
9
  ::
10
10
 
11
11
  Nuxt offers first-class support for end-to-end and unit testing of your Nuxt application via `@nuxt/test-utils`, a library of test utilities and configuration that currently powers the [tests we use on Nuxt itself](https://github.com/nuxt/nuxt/tree/main/test) and tests throughout the module ecosystem.
@@ -46,8 +46,8 @@ We currently ship an environment for unit testing code that needs a [Nuxt](https
46
46
  ```ts twoslash
47
47
  export default defineNuxtConfig({
48
48
  modules: [
49
- '@nuxt/test-utils/module'
50
- ]
49
+ '@nuxt/test-utils/module',
50
+ ],
51
51
  })
52
52
  ```
53
53
 
@@ -115,7 +115,7 @@ export default defineVitestConfig({
115
115
  // }
116
116
  // }
117
117
  // }
118
- }
118
+ },
119
119
  })
120
120
  ```
121
121
 
@@ -199,10 +199,10 @@ export default defineVitestConfig({
199
199
  mock: {
200
200
  intersectionObserver: true,
201
201
  indexedDb: true,
202
- }
203
- }
204
- }
205
- }
202
+ },
203
+ },
204
+ },
205
+ },
206
206
  })
207
207
  ```
208
208
 
@@ -222,8 +222,9 @@ For example:
222
222
 
223
223
  ```ts twoslash
224
224
  // @noErrors
225
- import { it, expect } from 'vitest'
225
+ import { expect, it } from 'vitest'
226
226
  import type { Component } from 'vue'
227
+
227
228
  declare module '#components' {
228
229
  export const SomeComponent: Component
229
230
  }
@@ -233,17 +234,16 @@ import { mountSuspended } from '@nuxt/test-utils/runtime'
233
234
  import { SomeComponent } from '#components'
234
235
 
235
236
  it('can mount some component', async () => {
236
- const component = await mountSuspended(SomeComponent)
237
- expect(component.text()).toMatchInlineSnapshot(
238
- '"This is an auto-imported component"'
239
- )
237
+ const component = await mountSuspended(SomeComponent)
238
+ expect(component.text()).toMatchInlineSnapshot(
239
+ '"This is an auto-imported component"',
240
+ )
240
241
  })
241
-
242
242
  ```
243
243
 
244
244
  ```ts twoslash
245
245
  // @noErrors
246
- import { it, expect } from 'vitest'
246
+ import { expect, it } from 'vitest'
247
247
  // ---cut---
248
248
  // tests/components/SomeComponents.nuxt.spec.ts
249
249
  import { mountSuspended } from '@nuxt/test-utils/runtime'
@@ -251,8 +251,8 @@ import App from '~/app.vue'
251
251
 
252
252
  // tests/App.nuxt.spec.ts
253
253
  it('can also mount an app', async () => {
254
- const component = await mountSuspended(App, { route: '/test' })
255
- expect(component.html()).toMatchInlineSnapshot(`
254
+ const component = await mountSuspended(App, { route: '/test' })
255
+ expect(component.html()).toMatchInlineSnapshot(`
256
256
  "<div>This is an auto-imported component</div>
257
257
  <div> I am a global component </div>
258
258
  <div>/</div>
@@ -275,8 +275,9 @@ Examples:
275
275
 
276
276
  ```ts twoslash
277
277
  // @noErrors
278
- import { it, expect } from 'vitest'
278
+ import { expect, it } from 'vitest'
279
279
  import type { Component } from 'vue'
280
+
280
281
  declare module '#components' {
281
282
  export const SomeComponent: Component
282
283
  }
@@ -294,7 +295,7 @@ it('can render some component', async () => {
294
295
 
295
296
  ```ts twoslash
296
297
  // @noErrors
297
- import { it, expect } from 'vitest'
298
+ import { expect, it } from 'vitest'
298
299
  // ---cut---
299
300
  // tests/App.nuxt.spec.ts
300
301
  import { renderSuspended } from '@nuxt/test-utils/runtime'
@@ -341,8 +342,8 @@ import { mockNuxtImport } from '@nuxt/test-utils/runtime'
341
342
  const { useStorageMock } = vi.hoisted(() => {
342
343
  return {
343
344
  useStorageMock: vi.fn(() => {
344
- return { value: 'mocked storage'}
345
- })
345
+ return { value: 'mocked storage' }
346
+ }),
346
347
  }
347
348
  })
348
349
 
@@ -369,20 +370,20 @@ import { mockComponent } from '@nuxt/test-utils/runtime'
369
370
 
370
371
  mockComponent('MyComponent', {
371
372
  props: {
372
- value: String
373
+ value: String,
373
374
  },
374
- setup(props) {
375
+ setup (props) {
375
376
  // ...
376
- }
377
+ },
377
378
  })
378
379
 
379
380
  // relative path or alias also works
380
- mockComponent('~/components/my-component.vue', async () => {
381
+ mockComponent('~/components/my-component.vue', () => {
381
382
  // or a factory function
382
383
  return defineComponent({
383
- setup(props) {
384
+ setup (props) {
384
385
  // ...
385
- }
386
+ },
386
387
  })
387
388
  })
388
389
 
@@ -401,10 +402,10 @@ mockComponent('MyComponent', async () => {
401
402
  const { ref, h } = await import('vue')
402
403
 
403
404
  return defineComponent({
404
- setup(props) {
405
+ setup (props) {
405
406
  const counter = ref(0)
406
407
  return () => h('div', null, counter.value)
407
- }
408
+ },
408
409
  })
409
410
  })
410
411
  ```
@@ -422,7 +423,7 @@ For example, to mock `/test/` endpoint, you can do:
422
423
  import { registerEndpoint } from '@nuxt/test-utils/runtime'
423
424
 
424
425
  registerEndpoint('/test/', () => ({
425
- test: 'test-field'
426
+ test: 'test-field',
426
427
  }))
427
428
  ```
428
429
 
@@ -433,11 +434,11 @@ import { registerEndpoint } from '@nuxt/test-utils/runtime'
433
434
 
434
435
  registerEndpoint('/test/', {
435
436
  method: 'POST',
436
- handler: () => ({ test: 'test-field' })
437
+ handler: () => ({ test: 'test-field' }),
437
438
  })
438
439
  ```
439
440
 
440
- > **Note**: If your requests in a component go to an external API, you can use `baseURL` and then make it empty using [Nuxt Environment Override Config](/docs/getting-started/configuration#environment-overrides) (`$test`) so all your requests will go to Nitro server.
441
+ > **Note**: If your requests in a component go to an external API, you can use `baseURL` and then make it empty using [Nuxt Environment Override Config](/docs/4.x/getting-started/configuration#environment-overrides) (`$test`) so all your requests will go to Nitro server.
441
442
 
442
443
  #### Conflict with End-To-End Testing
443
444
 
@@ -455,13 +456,12 @@ mockNuxtImport('useStorage', () => {
455
456
  return { value: 'mocked storage' }
456
457
  }
457
458
  })
458
-
459
459
  ```
460
460
 
461
461
  `app.e2e.spec.ts`
462
462
 
463
463
  ```ts twoslash
464
- import { setup, $fetch } from '@nuxt/test-utils/e2e'
464
+ import { $fetch, setup } from '@nuxt/test-utils/e2e'
465
465
 
466
466
  await setup({
467
467
  setupTimeout: 10000,
@@ -502,7 +502,7 @@ If you prefer to use `@vue/test-utils` on its own for unit testing in Nuxt, and
502
502
  test: {
503
503
  environment: 'happy-dom',
504
504
  },
505
- });
505
+ })
506
506
  ```
507
507
 
508
508
  3. Add a new command for test in your `package.json`
@@ -527,7 +527,7 @@ If you prefer to use `@vue/test-utils` on its own for unit testing in Nuxt, and
527
527
  5. Create a simple unit test for this newly created component `~/components/HelloWorld.spec.ts`
528
528
 
529
529
  ```ts twoslash
530
- import { describe, it, expect } from 'vitest'
530
+ import { describe, expect, it } from 'vitest'
531
531
  import { mount } from '@vue/test-utils'
532
532
 
533
533
  import HelloWorld from './HelloWorld.vue'
@@ -569,7 +569,7 @@ In each `describe` block where you are taking advantage of the `@nuxt/test-utils
569
569
 
570
570
  ```ts twoslash [test/my-test.spec.ts]
571
571
  import { describe, test } from 'vitest'
572
- import { setup, $fetch } from '@nuxt/test-utils/e2e'
572
+ import { $fetch, setup } from '@nuxt/test-utils/e2e'
573
573
 
574
574
  describe('My test', async () => {
575
575
  await setup({
@@ -624,7 +624,7 @@ Please use the options below for the `setup` method.
624
624
  - Type: `number | undefined`
625
625
  - Default: `undefined`
626
626
 
627
- - `host`: If provided, a URL to use as the test target instead of building and running a new server. Useful for running "real" end-to-end tests against a deployed version of your application, or against an already running local server (which may provide a significant reduction in test execution timings). See the [target host end-to-end example below](#target-host-end-to-end-example).
627
+ - `host`: If provided, a URL to use as the test target instead of building and running a new server. Useful for running "real" end-to-end tests against a deployed version of your application, or against an already running local server (which may provide a significant reduction in test execution timings). See the [target host end-to-end example below](/docs/4.x/getting-started/testing#target-host-end-to-end-example).
628
628
  - Type: `string`
629
629
  - Default: `undefined`
630
630
 
@@ -648,8 +648,8 @@ For local development or automated deploy pipelines, testing against a separate
648
648
  To utilize a separate target host for end-to-end tests, simply provide the `host` property of the `setup` function with the desired URL.
649
649
 
650
650
  ```ts
651
- import { setup, createPage } from '@nuxt/test-utils/e2e'
652
- import { describe, it, expect } from 'vitest'
651
+ import { createPage, setup } from '@nuxt/test-utils/e2e'
652
+ import { describe, expect, it } from 'vitest'
653
653
 
654
654
  describe('login page', async () => {
655
655
  await setup({
@@ -742,8 +742,8 @@ import type { ConfigOptions } from '@nuxt/test-utils/playwright'
742
742
  export default defineConfig<ConfigOptions>({
743
743
  use: {
744
744
  nuxt: {
745
- rootDir: fileURLToPath(new URL('.', import.meta.url))
746
- }
745
+ rootDir: fileURLToPath(new URL('.', import.meta.url)),
746
+ },
747
747
  },
748
748
  // ...
749
749
  })
@@ -770,8 +770,8 @@ import { expect, test } from '@nuxt/test-utils/playwright'
770
770
 
771
771
  test.use({
772
772
  nuxt: {
773
- rootDir: fileURLToPath(new URL('..', import.meta.url))
774
- }
773
+ rootDir: fileURLToPath(new URL('..', import.meta.url)),
774
+ },
775
775
  })
776
776
 
777
777
  test('test', async ({ page, goto }) => {
@@ -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/4.x/guide/going-further/nightly-release-channel) guide.
36
36
 
37
37
  ## Migrating to Nuxt 4
38
38
 
@@ -186,8 +186,8 @@ export default defineNuxtConfig({
186
186
  srcDir: '.',
187
187
  // This specifies the directory prefix for `router.options.ts` and `spa-loading-template.html`
188
188
  dir: {
189
- app: 'app'
190
- }
189
+ app: 'app',
190
+ },
191
191
  })
192
192
  ```
193
193
 
@@ -224,14 +224,14 @@ These changes have been made to improve memory usage and increase consistency wi
224
224
  It may be beneficial to extract any calls to `useAsyncData` that share an explicit key (and have custom options) into their own composable:
225
225
 
226
226
  ```ts [app/composables/useUserData.ts]
227
- export function useUserData(userId: string) {
227
+ export function useUserData (userId: string) {
228
228
  return useAsyncData(
229
229
  `user-${userId}`,
230
230
  () => fetchUser(userId),
231
- {
231
+ {
232
232
  deep: true,
233
- transform: (user) => ({ ...user, lastAccessed: new Date() })
234
- }
233
+ transform: user => ({ ...user, lastAccessed: new Date() }),
234
+ },
235
235
  )
236
236
  }
237
237
  ```
@@ -260,8 +260,8 @@ Alternatively, for now, you can disable this behaviour with:
260
260
  export default defineNuxtConfig({
261
261
  experimental: {
262
262
  granularCachedData: false,
263
- purgeCachedData: false
264
- }
263
+ purgeCachedData: false,
264
+ },
265
265
  })
266
266
  ```
267
267
 
@@ -271,7 +271,7 @@ export default defineNuxtConfig({
271
271
 
272
272
  #### What Changed
273
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.
274
+ The order in which modules are loaded when using [Nuxt layers](/docs/4.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.
275
275
 
276
276
  Now modules are loaded in the correct order:
277
277
 
@@ -303,23 +303,23 @@ Example of the new correct order:
303
303
  ```ts
304
304
  // Layer: my-layer/nuxt.config.ts
305
305
  export default defineNuxtConfig({
306
- modules: ['layer-module-1', 'layer-module-2']
306
+ modules: ['layer-module-1', 'layer-module-2'],
307
307
  })
308
308
 
309
309
  // Project: nuxt.config.ts
310
310
  export default defineNuxtConfig({
311
311
  extends: ['./my-layer'],
312
- modules: ['project-module-1', 'project-module-2']
312
+ modules: ['project-module-1', 'project-module-2'],
313
313
  })
314
314
 
315
315
  // Loading order (corrected):
316
316
  // 1. layer-module-1
317
- // 2. layer-module-2
317
+ // 2. layer-module-2
318
318
  // 3. project-module-1 (can override layer modules)
319
319
  // 4. project-module-2 (can override layer modules)
320
320
  ```
321
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.
322
+ If you encounter issues with module order dependencies due to needing to register a hook, consider using the [`modules:done` hook](/docs/4.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.
323
323
 
324
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
325
 
@@ -380,8 +380,8 @@ Alternatively, for now, you can disable this behaviour with:
380
380
  ```ts twoslash [nuxt.config.ts]
381
381
  export default defineNuxtConfig({
382
382
  experimental: {
383
- normalizeComponentNames: false
384
- }
383
+ normalizeComponentNames: false,
384
+ },
385
385
  })
386
386
  ```
387
387
 
@@ -420,14 +420,14 @@ useHead({
420
420
  * 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.
421
421
 
422
422
  ```ts
423
- import { TemplateParamsPlugin, AliasSortingPlugin } from '@unhead/vue/plugins'
423
+ import { AliasSortingPlugin, TemplateParamsPlugin } from '@unhead/vue/plugins'
424
424
 
425
425
  export default defineNuxtPlugin({
426
- setup() {
426
+ setup () {
427
427
  const unhead = injectHead()
428
428
  unhead.use(TemplateParamsPlugin)
429
429
  unhead.use(AliasSortingPlugin)
430
- }
430
+ },
431
431
  })
432
432
  ```
433
433
 
@@ -444,7 +444,7 @@ If you still have issues you may revert to the v1 behavior by enabling the `head
444
444
  export default defineNuxtConfig({
445
445
  unhead: {
446
446
  legacy: true,
447
- }
447
+ },
448
448
  })
449
449
  ```
450
450
 
@@ -483,7 +483,7 @@ Alternatively, you can revert to the previous behaviour with:
483
483
  export default defineNuxtConfig({
484
484
  experimental: {
485
485
  spaLoadingTemplateLocation: 'within',
486
- }
486
+ },
487
487
  })
488
488
  ```
489
489
 
@@ -527,8 +527,8 @@ This feature is fully configurable and you can revert to the previous behavior b
527
527
  ```ts twoslash [nuxt.config.ts]
528
528
  export default defineNuxtConfig({
529
529
  features: {
530
- inlineStyles: true
531
- }
530
+ inlineStyles: true,
531
+ },
532
532
  })
533
533
  ```
534
534
 
@@ -566,8 +566,8 @@ Alternatively, you can revert to the previous behaviour with:
566
566
  ```ts twoslash [nuxt.config.ts]
567
567
  export default defineNuxtConfig({
568
568
  experimental: {
569
- scanPageMeta: true
570
- }
569
+ scanPageMeta: true,
570
+ },
571
571
  })
572
572
  ```
573
573
 
@@ -607,8 +607,8 @@ Alternatively, you can disable this feature with:
607
607
  ```ts twoslash [nuxt.config.ts]
608
608
  export default defineNuxtConfig({
609
609
  experimental: {
610
- sharedPrerenderData: false
611
- }
610
+ sharedPrerenderData: false,
611
+ },
612
612
  })
613
613
  ```
614
614
 
@@ -632,24 +632,6 @@ If you were checking if `data.value` or `error.value` were `null`, you can updat
632
632
  You can automate this step by running `npx codemod@latest nuxt/4/default-data-error-value`
633
633
  ::
634
634
 
635
- If you encounter any issues you can revert back to the previous behavior with:
636
-
637
- ```ts twoslash [nuxt.config.ts]
638
- // @errors: 2353
639
- export default defineNuxtConfig({
640
- experimental: {
641
- defaults: {
642
- useAsyncData: {
643
- value: 'null',
644
- errorValue: 'null'
645
- }
646
- }
647
- }
648
- })
649
- ```
650
-
651
- Please report an issue if you are doing this, as we do not plan to keep this as configurable.
652
-
653
635
  ### Removal of deprecated `boolean` values for `dedupe` option when calling `refresh` in `useAsyncData` and `useFetch`
654
636
 
655
637
  🚦 **Impact Level**: Minimal
@@ -660,7 +642,7 @@ Previously it was possible to pass `dedupe: boolean` to `refresh`. These were al
660
642
 
661
643
  ```ts twoslash [app/app.vue]
662
644
  // @errors: 2322
663
- const { refresh } = await useAsyncData(async () => ({ message: 'Hello, Nuxt!' }))
645
+ const { refresh } = await useAsyncData(() => Promise.resolve({ message: 'Hello, Nuxt!' }))
664
646
 
665
647
  async function refreshData () {
666
648
  await refresh({ dedupe: true })
@@ -748,8 +730,8 @@ Alternatively, you can temporarily revert to the previous behavior with:
748
730
  ```ts twoslash [nuxt.config.ts]
749
731
  export default defineNuxtConfig({
750
732
  experimental: {
751
- pendingWhenIdle: true
752
- }
733
+ pendingWhenIdle: true,
734
+ },
753
735
  })
754
736
  ```
755
737
 
@@ -788,8 +770,8 @@ To opt out of this behavior:
788
770
  // Or globally in your Nuxt config
789
771
  export default defineNuxtConfig({
790
772
  experimental: {
791
- alwaysRunFetchOnKeyChange: true
792
- }
773
+ alwaysRunFetchOnKeyChange: true,
774
+ },
793
775
  })
794
776
  ```
795
777
 
@@ -822,10 +804,10 @@ In most cases, no migration steps are required, but if you rely on the reactivit
822
804
  experimental: {
823
805
  defaults: {
824
806
  useAsyncData: {
825
- deep: true
826
- }
827
- }
828
- }
807
+ deep: true,
808
+ },
809
+ },
810
+ },
829
811
  })
830
812
  ```
831
813
 
@@ -904,10 +886,10 @@ Probably no migration is necessary but if you wish to revert to previous behavio
904
886
  ```ts
905
887
  export default defineNuxtConfig({
906
888
  hooks: {
907
- 'app:resolve'(app) {
889
+ 'app:resolve' (app) {
908
890
  app.middleware = app.middleware.filter(mw => !/\/index\.[^/]+$/.test(mw.path))
909
- }
910
- }
891
+ },
892
+ },
911
893
  })
912
894
  ```
913
895
 
@@ -957,7 +939,7 @@ Finally, if you are using the template utilities (`serialize`, `importName`, `im
957
939
  ```ts
958
940
  import { genDynamicImport, genImport, genSafeVariableName } from 'knitwork'
959
941
 
960
- const serialize = (data: any) => JSON.stringify(data, null, 2).replace(/"{(.+)}"(?=,?$)/gm, r => JSON.parse(r).replace(/^{(.*)}$/, '$1'))
942
+ const serialize = (data: any) => JSON.stringify(data, null, 2).replace(/"\{(.+)\}"(?=,?$)/gm, r => JSON.parse(r).replace(/^\{(.*)\}$/, '$1'))
961
943
 
962
944
  const importSources = (sources: string | string[], { lazy = false } = {}) => {
963
945
  return toArray(sources).map((src) => {
@@ -1002,10 +984,10 @@ There are two approaches:
1002
984
  typescript: {
1003
985
  tsConfig: {
1004
986
  compilerOptions: {
1005
- noUncheckedIndexedAccess: false
1006
- }
1007
- }
1008
- }
987
+ noUncheckedIndexedAccess: false,
988
+ },
989
+ },
990
+ },
1009
991
  })
1010
992
  ```
1011
993
 
@@ -1090,16 +1072,16 @@ However, to take advantage of improved type checking, you can opt in to the new
1090
1072
  // Customize app/server TypeScript config
1091
1073
  tsConfig: {
1092
1074
  compilerOptions: {
1093
- strict: true
1094
- }
1075
+ strict: true,
1076
+ },
1095
1077
  },
1096
- // Customize build-time TypeScript config
1078
+ // Customize build-time TypeScript config
1097
1079
  nodeTsConfig: {
1098
1080
  compilerOptions: {
1099
- strict: true
1100
- }
1101
- }
1102
- }
1081
+ strict: true,
1082
+ },
1083
+ },
1084
+ },
1103
1085
  })
1104
1086
  ```
1105
1087
 
@@ -1195,7 +1177,7 @@ Static sites | ✅ | ✅ | ✅
1195
1177
 
1196
1178
  The migration guide provides a step-by-step comparison of Nuxt 2 features to Nuxt 3+ features and guidance to adapt your current application.
1197
1179
 
1198
- ::read-more{to="/docs/migration/overview"}
1180
+ ::read-more{to="/docs/4.x/migration/overview"}
1199
1181
  Check out the **guide to migrating from Nuxt 2 to Nuxt 3**.
1200
1182
  ::
1201
1183
 
@@ -1203,6 +1185,6 @@ Check out the **guide to migrating from Nuxt 2 to Nuxt 3**.
1203
1185
 
1204
1186
  If you prefer to progressively migrate your Nuxt 2 application to Nuxt 3, you can use Nuxt Bridge. Nuxt Bridge is a compatibility layer that allows you to use Nuxt 3+ features in Nuxt 2 with an opt-in mechanism.
1205
1187
 
1206
- ::read-more{to="/docs/bridge/overview"}
1188
+ ::read-more{to="/docs/4.x/bridge/overview"}
1207
1189
  **Migrate from Nuxt 2 to Nuxt Bridge**
1208
1190
  ::
@@ -7,19 +7,19 @@ 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
- ::card{icon="i-lucide-folders" title="Directory Structure" to="/docs/guide/directory-structure"}
10
+ ::card{icon="i-lucide-folders" title="Directory Structure" to="/docs/4.x/guide/directory-structure"}
14
11
  Learn about Nuxt directory structure and what benefits each directory or file offers.
15
12
  ::
16
- ::card{icon="i-lucide-star" title="Going Further" to="/docs/guide/going-further"}
13
+ ::card{icon="i-lucide-medal" title="Key Concepts" to="/docs/4.x/guide/concepts"}
14
+ Discover the main concepts behind Nuxt, from auto-import, hybrid rendering to its TypeScript support.
15
+ ::
16
+ ::card{icon="i-lucide-star" title="Going Further" to="/docs/4.x/guide/going-further"}
17
17
  Master Nuxt with advanced concepts like experimental features, hooks, modules, and more.
18
18
  ::
19
- ::card{icon="i-lucide-book-open" title="Recipes" to="/docs/guide/recipes"}
19
+ ::card{icon="i-lucide-book-open" title="Recipes" to="/docs/4.x/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"}
22
+ ::card{icon="i-lucide-square-check" title="Best Practices" to="/docs/4.x/guide/best-practices"}
23
23
  Learn about best practices when developing with Nuxt
24
24
  ::
25
25
  ::
@@ -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/4.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/4.x/api/commands/dev).
20
20
  ::
@@ -0,0 +1,18 @@
1
+ ---
2
+ title: ".output"
3
+ description: "Nuxt creates the .output/ directory when building your application for production."
4
+ head.title: ".output/"
5
+ navigation.icon: i-vscode-icons-folder-type-package
6
+ ---
7
+
8
+ ::important
9
+ This directory should be added to your [`.gitignore`](/docs/4.x/guide/directory-structure/gitignore) file to avoid pushing the build output to your repository.
10
+ ::
11
+
12
+ Use this directory to deploy your Nuxt application to production.
13
+
14
+ :read-more{to="/docs/4.x/getting-started/deployment"}
15
+
16
+ ::warning
17
+ You should not touch any files inside since the whole directory will be re-created when running [`nuxt build`](/docs/4.x/api/commands/build).
18
+ ::
@@ -2,4 +2,4 @@ title: app
2
2
  titleTemplate: '%s · Nuxt Directory Structure'
3
3
  head.title: "app/"
4
4
  defaultOpen: true
5
- icon: i-lucide-folders
5
+ icon: i-vscode-icons-folder-type-app
@@ -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/4.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/4.x/guide/directory-structure/public) directory.
15
15
 
16
- :read-more{to="/docs/getting-started/assets"}
16
+ :read-more{to="/docs/4.x/getting-started/assets"}