@nuxt/docs 3.19.2 → 3.19.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 (191) hide show
  1. package/1.getting-started/01.introduction.md +2 -2
  2. package/1.getting-started/02.installation.md +1 -0
  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 +58 -57
  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 +15 -13
  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 +80 -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 +89 -87
  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 +61 -52
  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 +4 -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 +44 -17
  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 +17 -17
  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 +55 -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 +36 -36
  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 +62 -62
  152. package/3.api/5.kit/12.resolving.md +2 -2
  153. package/3.api/5.kit/14.builder.md +1 -0
  154. package/3.api/5.kit/15.examples.md +2 -2
  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 +7 -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.plugins.md +6 -5
  163. package/3.api/6.advanced/1.hooks.md +2 -2
  164. package/3.api/6.advanced/2.import-meta.md +3 -3
  165. package/5.community/2.getting-help.md +1 -1
  166. package/5.community/3.reporting-bugs.md +1 -1
  167. package/5.community/4.contribution.md +6 -6
  168. package/5.community/5.framework-contribution.md +3 -3
  169. package/5.community/6.roadmap.md +1 -1
  170. package/6.bridge/1.overview.md +13 -13
  171. package/6.bridge/10.configuration.md +2 -1
  172. package/6.bridge/2.typescript.md +2 -2
  173. package/6.bridge/3.bridge-composition-api.md +6 -6
  174. package/6.bridge/4.plugins-and-middleware.md +9 -9
  175. package/6.bridge/5.nuxt3-compatible-api.md +19 -16
  176. package/6.bridge/6.meta.md +20 -19
  177. package/6.bridge/7.runtime-config.md +1 -1
  178. package/6.bridge/8.nitro.md +3 -3
  179. package/6.bridge/9.vite.md +4 -4
  180. package/7.migration/1.overview.md +2 -2
  181. package/7.migration/2.configuration.md +22 -20
  182. package/7.migration/20.module-authors.md +6 -6
  183. package/7.migration/3.auto-imports.md +3 -3
  184. package/7.migration/4.meta.md +20 -17
  185. package/7.migration/5.plugins-and-middleware.md +5 -5
  186. package/7.migration/6.pages-and-layouts.md +23 -19
  187. package/7.migration/7.component-options.md +14 -14
  188. package/7.migration/8.runtime-config.md +6 -6
  189. package/package.json +1 -1
  190. /package/2.guide/{1.concepts → 2.concepts}/.navigation.yml +0 -0
  191. /package/2.guide/{1.concepts → 2.concepts}/9.code-style.md +0 -0
@@ -12,7 +12,7 @@ Nuxt offers several built-in features that help you optimize performance of your
12
12
 
13
13
  ### Links
14
14
 
15
- [`<NuxtLink>`](/docs/api/components/nuxt-link) is a drop-in replacement for both Vue Router's `<RouterLink>` component and HTML's `<a>` tag. It intelligently determines whether the link is internal or external and renders it accordingly with available optimizations (prefetching, default attributes, etc.)
15
+ [`<NuxtLink>`](/docs/3.x/api/components/nuxt-link) is a drop-in replacement for both Vue Router's `<RouterLink>` component and HTML's `<a>` tag. It intelligently determines whether the link is internal or external and renders it accordingly with available optimizations (prefetching, default attributes, etc.)
16
16
 
17
17
  ```html
18
18
  <template>
@@ -34,8 +34,8 @@ export default defineNuxtConfig({
34
34
  nuxtLink: {
35
35
  prefetchOn: 'interaction',
36
36
  },
37
- }
38
- }
37
+ },
38
+ },
39
39
  })
40
40
  ```
41
41
 
@@ -51,18 +51,18 @@ Hybrid rendering allows different caching rules per route using Route Rules and
51
51
  export default defineNuxtConfig({
52
52
  routeRules: {
53
53
  '/': {
54
- prerender: true
54
+ prerender: true,
55
55
  },
56
56
  '/products/**': {
57
- swr: 3600
57
+ swr: 3600,
58
58
  },
59
59
  '/blog': {
60
- isr: 3600
60
+ isr: 3600,
61
61
  },
62
62
  '/admin/**': {
63
- ssr: false
63
+ ssr: false,
64
64
  },
65
- }
65
+ },
66
66
  })
67
67
  ```
68
68
 
@@ -110,7 +110,7 @@ To optimize your app, you may want to delay the hydration of some components unt
110
110
 
111
111
  ### Fetching data
112
112
 
113
- To avoid fetching same data twice (once on the server and once on client) Nuxt provides [`useFetch`](/docs/api/composables/use-fetch) and [`useAsyncData`](/docs/api/composables/use-async-data). They ensure that if an API call is made on the server, the data is forwarded to the client in the payload instead of being fetched again.
113
+ To avoid fetching same data twice (once on the server and once on client) Nuxt provides [`useFetch`](/docs/3.x/api/composables/use-fetch) and [`useAsyncData`](/docs/3.x/api/composables/use-async-data). They ensure that if an API call is made on the server, the data is forwarded to the client in the payload instead of being fetched again.
114
114
 
115
115
  :read-more{title="Data fetching" to="/docs/getting-started/data-fetching"}
116
116
 
@@ -126,7 +126,7 @@ In Nuxt we can use [Nuxt Image](https://image.nuxt.com/) module that is a plug-a
126
126
 
127
127
  :video-accordion{title="Watch the video by LearnVue about Nuxt Image" videoId="_UBff2eqGY0"}
128
128
 
129
- [`<NuxtImg>`](/docs/api/components/nuxt-img) is a drop-in replacement for the native `<img>` tag that comes with following enhancements:
129
+ [`<NuxtImg>`](/docs/3.x/api/components/nuxt-img) is a drop-in replacement for the native `<img>` tag that comes with following enhancements:
130
130
 
131
131
  * Uses built-in provider to optimize local and remote images
132
132
  * Converts `src` to provider optimized URLs with modern formats such as WebP or Avif
@@ -193,7 +193,7 @@ Nuxt Scripts provides an abstraction layer on top of third-party scripts, provid
193
193
 
194
194
  ```ts
195
195
  const { onLoaded, proxy } = useScriptGoogleAnalytics(
196
- {
196
+ {
197
197
  id: 'G-1234567',
198
198
  scriptOptions: {
199
199
  trigger: 'manual',
@@ -216,7 +216,7 @@ To improve performance, we need to first know how to measure it, starting with m
216
216
 
217
217
  ### Nuxi Analyze
218
218
 
219
- [This](/docs/api/commands/analyze) command of `nuxi` allows to analyze the production bundle or your Nuxt application. It leverages `vite-bundle-visualizer` (similar to `webpack-bundle-analyzer`) to generate a visual representation of your application's bundle, making it easier to identify which components take up the most space.
219
+ [This](/docs/3.x/api/commands/analyze) command of `nuxi` allows to analyze the production bundle or your Nuxt application. It leverages `vite-bundle-visualizer` (similar to `webpack-bundle-analyzer`) to generate a visual representation of your application's bundle, making it easier to identify which components take up the most space.
220
220
 
221
221
  When you see a large block in the visualization, it often signals an opportunity for optimization—whether by splitting it into smaller parts, implementing lazy loading, or replacing it with a more efficient alternative, especially for third-party libraries.
222
222
 
@@ -24,7 +24,10 @@ The content of the default slot will be tree-shaken out of the server build. (Th
24
24
  <div>
25
25
  <Sidebar />
26
26
  <!-- The <Comment> component will only be rendered on client-side -->
27
- <ClientOnly fallback-tag="span" fallback="Loading comments...">
27
+ <ClientOnly
28
+ fallback-tag="span"
29
+ fallback="Loading comments..."
30
+ >
28
31
  <Comment />
29
32
  </ClientOnly>
30
33
  </div>
@@ -40,7 +43,7 @@ The content of the default slot will be tree-shaken out of the server build. (Th
40
43
  <div>
41
44
  <Sidebar />
42
45
  <!-- This renders the "span" element on the server side -->
43
- <ClientOnly fallbackTag="span">
46
+ <ClientOnly fallback-tag="span">
44
47
  <!-- this component will only be rendered on client side -->
45
48
  <Comments />
46
49
  <template #fallback>
@@ -64,7 +67,7 @@ const nuxtWelcomeRef = useTemplateRef('nuxtWelcomeRef')
64
67
 
65
68
  // The watch will be triggered when the component is available
66
69
  watch(nuxtWelcomeRef, () => {
67
- console.log('<NuxtWelcome /> mounted')
70
+ console.log('<NuxtWelcome /> mounted')
68
71
  }, { once: true })
69
72
  </script>
70
73
 
@@ -55,12 +55,15 @@ This component is experimental and in order to use it you must enable the `exper
55
55
  - **default**: `false`
56
56
 
57
57
  ```vue
58
- <template>
59
- <!-- render <span>Hello world</span> server-side if the default slot fails to render -->
60
- <NuxtClientFallback fallback-tag="span" fallback="Hello world">
61
- <BrokeInSsr />
62
- </NuxtClientFallback>
63
- </template>
58
+ <template>
59
+ <!-- render <span>Hello world</span> server-side if the default slot fails to render -->
60
+ <NuxtClientFallback
61
+ fallback-tag="span"
62
+ fallback="Hello world"
63
+ >
64
+ <BrokeInSSR />
65
+ </NuxtClientFallback>
66
+ </template>
64
67
  ```
65
68
 
66
69
  ## Slots
@@ -10,7 +10,7 @@ links:
10
10
 
11
11
  `<NuxtPicture>` is a drop-in replacement for the native `<picture>` tag.
12
12
 
13
- Usage of `<NuxtPicture>` is almost identical to [`<NuxtImg>`](/docs/api/components/nuxt-img) but it also allows serving modern formats like `webp` when possible.
13
+ Usage of `<NuxtPicture>` is almost identical to [`<NuxtImg>`](/docs/3.x/api/components/nuxt-img) but it also allows serving modern formats like `webp` when possible.
14
14
 
15
15
  Learn more about the [`<picture>` tag on MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture).
16
16
 
@@ -15,7 +15,10 @@ The `to` target of [`<Teleport>`](https://vuejs.org/guide/built-ins/teleport.htm
15
15
  Open Modal
16
16
  </button>
17
17
  <Teleport to="#teleports">
18
- <div v-if="open" class="modal">
18
+ <div
19
+ v-if="open"
20
+ class="modal"
21
+ >
19
22
  <p>Hello from the modal!</p>
20
23
  <button @click="open = false">
21
24
  Close
@@ -16,7 +16,7 @@ This component is available in Nuxt v3.12+.
16
16
 
17
17
  ## Usage
18
18
 
19
- Add `<NuxtRouteAnnouncer/>` in your [`app.vue`](/docs/guide/directory-structure/app) or [`layouts/`](/docs/guide/directory-structure/layouts) to enhance accessibility by informing assistive technologies about page title changes. This ensures that navigational changes are announced to users relying on screen readers.
19
+ Add `<NuxtRouteAnnouncer/>` in your [`app.vue`](/docs/3.x/guide/directory-structure/app) or [`layouts/`](/docs/3.x/guide/directory-structure/layouts) to enhance accessibility by informing assistive technologies about page title changes. This ensures that navigational changes are announced to users relying on screen readers.
20
20
 
21
21
  ```vue [app.vue]
22
22
  <template>
@@ -32,13 +32,13 @@ Add `<NuxtRouteAnnouncer/>` in your [`app.vue`](/docs/guide/directory-structure/
32
32
  You can pass custom HTML or components through the route announcer's default slot.
33
33
 
34
34
  ```vue
35
- <template>
36
- <NuxtRouteAnnouncer>
37
- <template #default="{ message }">
38
- <p>{{ message }} was loaded.</p>
39
- </template>
40
- </NuxtRouteAnnouncer>
41
- </template>
35
+ <template>
36
+ <NuxtRouteAnnouncer>
37
+ <template #default="{ message }">
38
+ <p>{{ message }} was loaded.</p>
39
+ </template>
40
+ </NuxtRouteAnnouncer>
41
+ </template>
42
42
  ```
43
43
 
44
44
  ## Props
@@ -52,5 +52,5 @@ To achieve full customization, you can implement your own one based on [its sour
52
52
  ::
53
53
 
54
54
  ::callout
55
- You can hook into the underlying announcer instance using [the `useRouteAnnouncer` composable](/docs/api/composables/use-route-announcer), which allows you to set a custom announcement message.
55
+ You can hook into the underlying announcer instance using [the `useRouteAnnouncer` composable](/docs/3.x/api/composables/use-route-announcer), which allows you to set a custom announcement message.
56
56
  ::
@@ -56,7 +56,10 @@ The [BCP 47 language tag](https://datatracker.ietf.org/doc/html/rfc5646) for for
56
56
 
57
57
  ```vue
58
58
  <template>
59
- <NuxtTime :datetime="Date.now()" locale="fr-FR" />
59
+ <NuxtTime
60
+ :datetime="Date.now()"
61
+ locale="fr-FR"
62
+ />
60
63
  </template>
61
64
  ```
62
65
 
@@ -66,8 +69,8 @@ The component accepts any property from the [Intl.DateTimeFormat](https://develo
66
69
 
67
70
  ```vue
68
71
  <template>
69
- <NuxtTime
70
- :datetime="Date.now()"
72
+ <NuxtTime
73
+ :datetime="Date.now()"
71
74
  year="numeric"
72
75
  month="long"
73
76
  day="numeric"
@@ -90,7 +93,10 @@ Enables relative time formatting using the Intl.RelativeTimeFormat API:
90
93
  ```vue
91
94
  <template>
92
95
  <!-- Shows something like "5 minutes ago" -->
93
- <NuxtTime :datetime="Date.now() - 5 * 60 * 1000" relative />
96
+ <NuxtTime
97
+ :datetime="Date.now() - 5 * 60 * 1000"
98
+ relative
99
+ />
94
100
  </template>
95
101
  ```
96
102
 
@@ -100,9 +106,9 @@ When `relative` is set to `true`, the component also accepts properties from [In
100
106
 
101
107
  ```vue
102
108
  <template>
103
- <NuxtTime
104
- :datetime="Date.now() - 3 * 24 * 60 * 60 * 1000"
105
- relative
109
+ <NuxtTime
110
+ :datetime="Date.now() - 3 * 24 * 60 * 60 * 1000"
111
+ relative
106
112
  numeric="auto"
107
113
  style="long"
108
114
  />
@@ -125,8 +131,8 @@ This would output something like: "3 days ago" or "last Friday" depending on the
125
131
 
126
132
  ```vue
127
133
  <template>
128
- <NuxtTime
129
- :datetime="Date.now()"
134
+ <NuxtTime
135
+ :datetime="Date.now()"
130
136
  weekday="long"
131
137
  year="numeric"
132
138
  month="short"
@@ -134,7 +140,7 @@ This would output something like: "3 days ago" or "last Friday" depending on the
134
140
  hour="numeric"
135
141
  minute="numeric"
136
142
  second="numeric"
137
- timeZoneName="short"
143
+ time-zone-name="short"
138
144
  />
139
145
  </template>
140
146
  ```
@@ -145,15 +151,24 @@ This would output something like: "3 days ago" or "last Friday" depending on the
145
151
  <template>
146
152
  <div>
147
153
  <p>
148
- <NuxtTime :datetime="Date.now() - 30 * 1000" relative />
154
+ <NuxtTime
155
+ :datetime="Date.now() - 30 * 1000"
156
+ relative
157
+ />
149
158
  <!-- 30 seconds ago -->
150
159
  </p>
151
- <p>
152
- <NuxtTime :datetime="Date.now() - 45 * 60 * 1000" relative />
160
+ <p>
161
+ <NuxtTime
162
+ :datetime="Date.now() - 45 * 60 * 1000"
163
+ relative
164
+ />
153
165
  <!-- 45 minutes ago -->
154
166
  </p>
155
167
  <p>
156
- <NuxtTime :datetime="Date.now() + 2 * 24 * 60 * 60 * 1000" relative />
168
+ <NuxtTime
169
+ :datetime="Date.now() + 2 * 24 * 60 * 60 * 1000"
170
+ relative
171
+ />
157
172
  <!-- in 2 days -->
158
173
  </p>
159
174
  </div>
@@ -165,9 +180,21 @@ This would output something like: "3 days ago" or "last Friday" depending on the
165
180
  ```vue
166
181
  <template>
167
182
  <div>
168
- <NuxtTime :datetime="Date.now()" locale="en-US" weekday="long" />
169
- <NuxtTime :datetime="Date.now()" locale="fr-FR" weekday="long" />
170
- <NuxtTime :datetime="Date.now()" locale="ja-JP" weekday="long" />
183
+ <NuxtTime
184
+ :datetime="Date.now()"
185
+ locale="en-US"
186
+ weekday="long"
187
+ />
188
+ <NuxtTime
189
+ :datetime="Date.now()"
190
+ locale="fr-FR"
191
+ weekday="long"
192
+ />
193
+ <NuxtTime
194
+ :datetime="Date.now()"
195
+ locale="ja-JP"
196
+ weekday="long"
197
+ />
171
198
  </div>
172
199
  </template>
173
200
  ```
@@ -8,7 +8,7 @@ links:
8
8
  size: xs
9
9
  ---
10
10
 
11
- `<NuxtPage>` is a built-in component that comes with Nuxt. It lets you display top-level or nested pages located in the [`pages/`](/docs/guide/directory-structure/pages) directory.
11
+ `<NuxtPage>` is a built-in component that comes with Nuxt. It lets you display top-level or nested pages located in the [`pages/`](/docs/3.x/guide/directory-structure/pages) directory.
12
12
 
13
13
  ::note
14
14
  `<NuxtPage>` is a wrapper around [`<RouterView>`](https://router.vuejs.org/api/interfaces/RouterViewProps.html#interface-routerviewprops) from Vue Router. It should be used instead of `<RouterView>` because the former takes additional care of internal states. Otherwise, `useRoute()` may return incorrect paths.
@@ -18,7 +18,7 @@ links:
18
18
 
19
19
  ```vue
20
20
  <template>
21
- <RouterView #default="{ Component }">
21
+ <RouterView v-slot="{ Component }">
22
22
  <!-- Optional, when using transitions -->
23
23
  <Transition>
24
24
  <!-- Optional, when using keep-alive -->
@@ -79,12 +79,12 @@ You can also use a dynamic key based on the current route:
79
79
  Don't use `$route` object here as it can cause problems with how `<NuxtPage>` renders pages with `<Suspense>`.
80
80
  ::
81
81
 
82
- Alternatively, `pageKey` can be passed as a `key` value via [`definePageMeta`](/docs/api/utils/define-page-meta) from the `<script>` section of your Vue component in the `/pages` directory.
82
+ Alternatively, `pageKey` can be passed as a `key` value via [`definePageMeta`](/docs/3.x/api/utils/define-page-meta) from the `<script>` section of your Vue component in the `/pages` directory.
83
83
 
84
84
  ```vue [pages/my-page.vue]
85
85
  <script setup lang="ts">
86
86
  definePageMeta({
87
- key: route => route.fullPath
87
+ key: route => route.fullPath,
88
88
  })
89
89
  </script>
90
90
  ```
@@ -22,7 +22,7 @@ You can use `<NuxtLayout />` component to activate the `default` layout on `app.
22
22
 
23
23
  ## Props
24
24
 
25
- - `name`: Specify a layout name to be rendered, can be a string, reactive reference or a computed property. It **must** match the name of the corresponding layout file in the [`layouts/`](/docs/guide/directory-structure/layouts) directory.
25
+ - `name`: Specify a layout name to be rendered, can be a string, reactive reference or a computed property. It **must** match the name of the corresponding layout file in the [`layouts/`](/docs/3.x/guide/directory-structure/layouts) directory.
26
26
  - **type**: `string`
27
27
  - **default**: `default`
28
28
 
@@ -55,7 +55,7 @@ Please note the layout name is normalized to kebab-case, so if your layout file
55
55
  Read more about dynamic layouts.
56
56
  ::
57
57
 
58
- - `fallback`: If an invalid layout is passed to the `name` prop, no layout will be rendered. Specify a `fallback` layout to be rendered in this scenario. It **must** match the name of the corresponding layout file in the [`layouts/`](/docs/guide/directory-structure/layouts) directory.
58
+ - `fallback`: If an invalid layout is passed to the `name` prop, no layout will be rendered. Specify a `fallback` layout to be rendered in this scenario. It **must** match the name of the corresponding layout file in the [`layouts/`](/docs/3.x/guide/directory-structure/layouts) directory.
59
59
  - **type**: `string`
60
60
  - **default**: `null`
61
61
 
@@ -66,8 +66,11 @@ Read more about dynamic layouts.
66
66
  ```vue [pages/some-page.vue]
67
67
  <template>
68
68
  <div>
69
- <NuxtLayout name="custom" title="I am a custom layout">
70
- <-- ... -->
69
+ <NuxtLayout
70
+ name="custom"
71
+ title="I am a custom layout"
72
+ >
73
+ <!-- ... -->
71
74
  </NuxtLayout>
72
75
  </div>
73
76
  </template>
@@ -93,7 +96,9 @@ console.log(layoutCustomProps.title) // I am a custom layout
93
96
  <template>
94
97
  <div>
95
98
  <NuxtLayout name="custom">
96
- <template #header> Some header template content. </template>
99
+ <template #header>
100
+ Some header template content.
101
+ </template>
97
102
  </NuxtLayout>
98
103
  </div>
99
104
  </template>
@@ -139,7 +144,7 @@ function logFoo () {
139
144
  <script setup lang="ts">
140
145
  const foo = () => console.log('foo')
141
146
  defineExpose({
142
- foo
147
+ foo,
143
148
  })
144
149
  </script>
145
150
 
@@ -67,7 +67,10 @@ For static files in the `/public` directory, such as PDFs or images, use the `ex
67
67
 
68
68
  ```vue [pages/index.vue]
69
69
  <template>
70
- <NuxtLink to="/example-report.pdf" external>
70
+ <NuxtLink
71
+ to="/example-report.pdf"
72
+ external
73
+ >
71
74
  Download Report
72
75
  </NuxtLink>
73
76
  </template>
@@ -79,7 +82,10 @@ When pointing to a different application on the same domain, using the `external
79
82
 
80
83
  ```vue [pages/index.vue]
81
84
  <template>
82
- <NuxtLink to="/another-app" external>
85
+ <NuxtLink
86
+ to="/another-app"
87
+ external
88
+ >
83
89
  Go to Another App
84
90
  </NuxtLink>
85
91
  </template>
@@ -117,12 +123,18 @@ When you need to overwrite this behavior you can use the `rel` or `noRel` props.
117
123
  </NuxtLink>
118
124
  <!-- <a href="https://twitter.com/nuxt_js" rel="noopener noreferrer">...</a> -->
119
125
 
120
- <NuxtLink to="https://discord.nuxtjs.org" rel="noopener">
126
+ <NuxtLink
127
+ to="https://discord.nuxtjs.org"
128
+ rel="noopener"
129
+ >
121
130
  Nuxt Discord
122
131
  </NuxtLink>
123
132
  <!-- <a href="https://discord.nuxtjs.org" rel="noopener">...</a> -->
124
133
 
125
- <NuxtLink to="/about" target="_blank">About page</NuxtLink>
134
+ <NuxtLink
135
+ to="/about"
136
+ target="_blank"
137
+ >About page</NuxtLink>
126
138
  <!-- <a href="/about" target="_blank" rel="noopener noreferrer">...</a> -->
127
139
  </template>
128
140
  ```
@@ -131,7 +143,10 @@ A `noRel` prop can be used to prevent the default `rel` attribute from being add
131
143
 
132
144
  ```vue [app.vue]
133
145
  <template>
134
- <NuxtLink to="https://github.com/nuxt" no-rel>
146
+ <NuxtLink
147
+ to="https://github.com/nuxt"
148
+ no-rel
149
+ >
135
150
  Nuxt GitHub
136
151
  </NuxtLink>
137
152
  <!-- <a href="https://github.com/nuxt">...</a> -->
@@ -147,8 +162,13 @@ A `noRel` prop can be used to prevent the default `rel` attribute from being add
147
162
  Nuxt automatically includes smart prefetching. That means it detects when a link is visible (by default), either in the viewport or when scrolling and prefetches the JavaScript for those pages so that they are ready when the user clicks the link. Nuxt only loads the resources when the browser isn't busy and skips prefetching if your connection is offline or if you only have 2g connection.
148
163
 
149
164
  ```vue [pages/index.vue]
150
- <NuxtLink to="/about" no-prefetch>About page not pre-fetched</NuxtLink>
151
- <NuxtLink to="/about" :prefetch="false">About page not pre-fetched</NuxtLink>
165
+ <NuxtLink to="/about" no-prefetch>
166
+ About page not pre-fetched
167
+ </NuxtLink>
168
+
169
+ <NuxtLink to="/about" :prefetch="false">
170
+ About page not pre-fetched
171
+ </NuxtLink>
152
172
  ```
153
173
 
154
174
  ### Custom Prefetch Triggers
@@ -238,7 +258,7 @@ When not using `external`, `<NuxtLink>` supports all Vue Router's [`RouterLink`
238
258
  - `href`: An alias for `to`. If used with `to`, `href` will be ignored
239
259
  - `noRel`: If set to `true`, no `rel` attribute will be added to the external link
240
260
  - `external`: Forces the link to be rendered as an `<a>` tag instead of a Vue Router `RouterLink`.
241
- - `prefetch`: When enabled will prefetch middleware, layouts and payloads (when using [payloadExtraction](/docs/api/nuxt-config#crossoriginprefetch)) of links in the viewport. Used by the experimental [crossOriginPrefetch](/docs/api/nuxt-config#crossoriginprefetch) config.
261
+ - `prefetch`: When enabled will prefetch middleware, layouts and payloads (when using [payloadExtraction](/docs/3.x/api/nuxt-config#crossoriginprefetch)) of links in the viewport. Used by the experimental [crossOriginPrefetch](/docs/3.x/api/nuxt-config#crossoriginprefetch) config.
242
262
  - `prefetchOn`: Allows custom control of when to prefetch links. Possible options are `interaction` and `visibility` (default). You can also pass an object for full control, for example: `{ interaction: true, visibility: true }`. This prop is only used when `prefetch` is enabled (default) and `noPrefetch` is not set.
243
263
  - `noPrefetch`: Disables prefetching.
244
264
  - `prefetchedClass`: A class to apply to links that have been prefetched.
@@ -256,7 +276,7 @@ Defaults can be overwritten, see [overwriting defaults](#overwriting-defaults) i
256
276
 
257
277
  ### In Nuxt Config
258
278
 
259
- You can overwrite some `<NuxtLink>` defaults in your [`nuxt.config`](/docs/api/nuxt-config#defaults)
279
+ You can overwrite some `<NuxtLink>` defaults in your [`nuxt.config`](/docs/3.x/api/nuxt-config#defaults)
260
280
 
261
281
  ::important
262
282
  These options will likely be moved elsewhere in the future, such as into `app.config` or into the `app/` directory.
@@ -273,12 +293,12 @@ export default defineNuxtConfig({
273
293
  activeClass: 'router-link-active',
274
294
  exactActiveClass: 'router-link-exact-active',
275
295
  prefetchedClass: undefined, // can be any valid string class name
276
- trailingSlash: undefined // can be 'append' or 'remove'
296
+ trailingSlash: undefined, // can be 'append' or 'remove'
277
297
  prefetch: true,
278
- prefetchOn: { visibility: true }
279
- }
280
- }
281
- }
298
+ prefetchOn: { visibility: true },
299
+ },
300
+ },
301
+ },
282
302
  })
283
303
  ```
284
304
 
@@ -286,7 +306,7 @@ export default defineNuxtConfig({
286
306
 
287
307
  You can overwrite `<NuxtLink>` defaults by creating your own link component using `defineNuxtLink`.
288
308
 
289
- ```js [components/MyNuxtLink.ts]
309
+ ```ts [components/MyNuxtLink.ts]
290
310
  export default defineNuxtLink({
291
311
  componentName: 'MyNuxtLink',
292
312
  /* see signature below for more */
@@ -299,10 +319,10 @@ You can then use `<MyNuxtLink />` component as usual with your new defaults.
299
319
 
300
320
  ```ts
301
321
  interface NuxtLinkOptions {
302
- componentName?: string;
303
- externalRelAttribute?: string;
304
- activeClass?: string;
305
- exactActiveClass?: string;
322
+ componentName?: string
323
+ externalRelAttribute?: string
324
+ activeClass?: string
325
+ exactActiveClass?: string
306
326
  trailingSlash?: 'append' | 'remove'
307
327
  prefetch?: boolean
308
328
  prefetchedClass?: string
@@ -311,7 +331,7 @@ interface NuxtLinkOptions {
311
331
  interaction: boolean
312
332
  }>
313
333
  }
314
- function defineNuxtLink(options: NuxtLinkOptions): Component {}
334
+ function defineNuxtLink (options: NuxtLinkOptions): Component {}
315
335
  ```
316
336
 
317
337
  - `componentName`: A name for the component. Default is `NuxtLink`.
@@ -10,7 +10,7 @@ links:
10
10
 
11
11
  ## Usage
12
12
 
13
- Add `<NuxtLoadingIndicator/>` in your [`app.vue`](/docs/guide/directory-structure/app) or [`layouts/`](/docs/guide/directory-structure/layouts).
13
+ Add `<NuxtLoadingIndicator/>` in your [`app.vue`](/docs/3.x/guide/directory-structure/app) or [`layouts/`](/docs/3.x/guide/directory-structure/layouts).
14
14
 
15
15
  ```vue [app.vue]
16
16
  <template>
@@ -42,7 +42,7 @@ To achieve full customization, you can implement your own one based on [its sour
42
42
  ::
43
43
 
44
44
  ::note
45
- You can hook into the underlying indicator instance using [the `useLoadingIndicator` composable](/docs/api/composables/use-loading-indicator), which will allow you to trigger start/finish events yourself.
45
+ You can hook into the underlying indicator instance using [the `useLoadingIndicator` composable](/docs/3.x/api/composables/use-loading-indicator), which will allow you to trigger start/finish events yourself.
46
46
  ::
47
47
 
48
48
  ::tip
@@ -29,16 +29,18 @@ The `<NuxtErrorBoundary>` uses Vue's [`onErrorCaptured`](https://vuejs.org/api/c
29
29
  - `#error`: Specify a fallback content to display in case of error.
30
30
 
31
31
  ```vue
32
- <template>
33
- <NuxtErrorBoundary>
34
- <!-- ... -->
35
- <template #error="{ error, clearError }">
36
- <p>An error occurred: {{ error }}</p>
32
+ <template>
33
+ <NuxtErrorBoundary>
34
+ <!-- ... -->
35
+ <template #error="{ error, clearError }">
36
+ <p>An error occurred: {{ error }}</p>
37
37
 
38
- <button @click="clearError">Clear error</button>
39
- </template>
40
- </NuxtErrorBoundary>
41
- </template>
38
+ <button @click="clearError">
39
+ Clear error
40
+ </button>
41
+ </template>
42
+ </NuxtErrorBoundary>
43
+ </template>
42
44
  ```
43
45
 
44
46
  :read-more{to="/docs/getting-started/error-handling"}
@@ -24,8 +24,8 @@ Call `onPrehydrate` in the setup function of a Vue component (e.g., in `<script
24
24
  ## Type
25
25
 
26
26
  ```ts [Signature]
27
- export function onPrehydrate(callback: (el: HTMLElement) => void): void
28
- export function onPrehydrate(callback: string | ((el: HTMLElement) => void), key?: string): undefined | string
27
+ export function onPrehydrate (callback: (el: HTMLElement) => void): void
28
+ export function onPrehydrate (callback: string | ((el: HTMLElement) => void), key?: string): undefined | string
29
29
  ```
30
30
 
31
31
  ## Parameters