@nuxt/docs-nightly 4.1.3-29313386.edc02e27 → 4.1.3-29316215.910d159d

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 (165) hide show
  1. package/1.getting-started/01.introduction.md +4 -4
  2. package/1.getting-started/02.installation.md +1 -1
  3. package/1.getting-started/03.configuration.md +25 -25
  4. package/1.getting-started/04.views.md +3 -3
  5. package/1.getting-started/05.assets.md +9 -3
  6. package/1.getting-started/06.styling.md +53 -43
  7. package/1.getting-started/07.routing.md +9 -9
  8. package/1.getting-started/08.seo-meta.md +50 -37
  9. package/1.getting-started/09.transitions.md +38 -33
  10. package/1.getting-started/10.data-fetching.md +61 -53
  11. package/1.getting-started/11.state-management.md +19 -12
  12. package/1.getting-started/12.error-handling.md +17 -15
  13. package/1.getting-started/13.server.md +8 -8
  14. package/1.getting-started/14.layers.md +19 -13
  15. package/1.getting-started/15.prerendering.md +28 -28
  16. package/1.getting-started/16.deployment.md +8 -8
  17. package/1.getting-started/17.testing.md +42 -42
  18. package/1.getting-started/18.upgrade.md +50 -68
  19. package/2.guide/0.index.md +5 -5
  20. package/2.guide/1.directory-structure/0.output.md +1 -1
  21. package/2.guide/1.directory-structure/1.app/1.assets.md +1 -1
  22. package/2.guide/1.directory-structure/1.app/1.components.md +40 -23
  23. package/2.guide/1.directory-structure/1.app/1.composables.md +9 -9
  24. package/2.guide/1.directory-structure/1.app/1.layouts.md +12 -8
  25. package/2.guide/1.directory-structure/1.app/1.middleware.md +23 -17
  26. package/2.guide/1.directory-structure/1.app/1.pages.md +25 -23
  27. package/2.guide/1.directory-structure/1.app/1.plugins.md +17 -17
  28. package/2.guide/1.directory-structure/1.app/1.utils.md +3 -3
  29. package/2.guide/1.directory-structure/1.app/3.app-config.md +7 -7
  30. package/2.guide/1.directory-structure/1.app/3.app.md +3 -3
  31. package/2.guide/1.directory-structure/1.app/3.error.md +4 -4
  32. package/2.guide/1.directory-structure/1.content.md +4 -1
  33. package/2.guide/1.directory-structure/1.modules.md +5 -5
  34. package/2.guide/1.directory-structure/1.public.md +1 -1
  35. package/2.guide/1.directory-structure/1.server.md +30 -30
  36. package/2.guide/1.directory-structure/1.shared.md +3 -3
  37. package/2.guide/1.directory-structure/2.env.md +3 -3
  38. package/2.guide/1.directory-structure/2.nuxtrc.md +1 -1
  39. package/2.guide/1.directory-structure/3.nuxt-config.md +1 -1
  40. package/2.guide/2.concepts/1.auto-imports.md +15 -15
  41. package/2.guide/2.concepts/10.nuxt-lifecycle.md +7 -7
  42. package/2.guide/2.concepts/2.vuejs-development.md +9 -9
  43. package/2.guide/2.concepts/3.rendering.md +17 -15
  44. package/2.guide/2.concepts/4.server-engine.md +1 -1
  45. package/2.guide/2.concepts/5.modules.md +3 -3
  46. package/2.guide/2.concepts/7.esm.md +16 -14
  47. package/2.guide/2.concepts/8.typescript.md +4 -4
  48. package/2.guide/3.going-further/1.events.md +3 -3
  49. package/2.guide/3.going-further/1.experimental-features.md +238 -77
  50. package/2.guide/3.going-further/1.features.md +44 -9
  51. package/2.guide/3.going-further/1.internals.md +15 -15
  52. package/2.guide/3.going-further/10.runtime-config.md +8 -8
  53. package/2.guide/3.going-further/11.nightly-release-channel.md +1 -1
  54. package/2.guide/3.going-further/2.hooks.md +11 -11
  55. package/2.guide/3.going-further/3.modules.md +83 -81
  56. package/2.guide/3.going-further/4.kit.md +5 -5
  57. package/2.guide/3.going-further/6.nuxt-app.md +4 -4
  58. package/2.guide/3.going-further/7.layers.md +51 -42
  59. package/2.guide/3.going-further/9.debugging.md +2 -2
  60. package/2.guide/4.recipes/1.custom-routing.md +19 -19
  61. package/2.guide/4.recipes/2.vite-plugin.md +3 -3
  62. package/2.guide/4.recipes/3.custom-usefetch.md +10 -10
  63. package/2.guide/4.recipes/4.sessions-and-authentication.md +34 -20
  64. package/2.guide/5.best-practices/performance.md +13 -13
  65. package/3.api/1.components/1.client-only.md +6 -3
  66. package/3.api/1.components/1.nuxt-client-fallback.md +10 -7
  67. package/3.api/1.components/11.teleports.md +5 -2
  68. package/3.api/1.components/12.nuxt-route-announcer.md +7 -7
  69. package/3.api/1.components/13.nuxt-time.md +44 -17
  70. package/3.api/1.components/2.nuxt-page.md +4 -4
  71. package/3.api/1.components/3.nuxt-layout.md +13 -8
  72. package/3.api/1.components/4.nuxt-link.md +40 -20
  73. package/3.api/1.components/5.nuxt-loading-indicator.md +1 -1
  74. package/3.api/1.components/6.nuxt-error-boundary.md +12 -10
  75. package/3.api/2.composables/on-prehydrate.md +2 -2
  76. package/3.api/2.composables/use-app-config.md +1 -1
  77. package/3.api/2.composables/use-async-data.md +14 -14
  78. package/3.api/2.composables/use-cookie.md +27 -19
  79. package/3.api/2.composables/use-error.md +2 -2
  80. package/3.api/2.composables/use-fetch.md +17 -17
  81. package/3.api/2.composables/use-head-safe.md +5 -5
  82. package/3.api/2.composables/use-head.md +3 -3
  83. package/3.api/2.composables/use-hydration.md +5 -5
  84. package/3.api/2.composables/use-lazy-async-data.md +2 -2
  85. package/3.api/2.composables/use-lazy-fetch.md +2 -2
  86. package/3.api/2.composables/use-loading-indicator.md +10 -10
  87. package/3.api/2.composables/use-nuxt-app.md +10 -10
  88. package/3.api/2.composables/use-nuxt-data.md +7 -7
  89. package/3.api/2.composables/use-preview-mode.md +12 -15
  90. package/3.api/2.composables/use-request-fetch.md +1 -1
  91. package/3.api/2.composables/use-request-headers.md +3 -3
  92. package/3.api/2.composables/use-response-header.md +7 -8
  93. package/3.api/2.composables/use-route-announcer.md +3 -3
  94. package/3.api/2.composables/use-router.md +6 -4
  95. package/3.api/2.composables/use-runtime-config.md +11 -11
  96. package/3.api/2.composables/use-runtime-hook.md +1 -1
  97. package/3.api/2.composables/use-seo-meta.md +3 -3
  98. package/3.api/2.composables/use-server-seo-meta.md +3 -3
  99. package/3.api/2.composables/use-state.md +4 -4
  100. package/3.api/3.utils/$fetch.md +6 -4
  101. package/3.api/3.utils/abort-navigation.md +2 -2
  102. package/3.api/3.utils/add-route-middleware.md +3 -3
  103. package/3.api/3.utils/call-once.md +5 -5
  104. package/3.api/3.utils/clear-error.md +2 -2
  105. package/3.api/3.utils/clear-nuxt-data.md +2 -2
  106. package/3.api/3.utils/clear-nuxt-state.md +2 -2
  107. package/3.api/3.utils/create-error.md +2 -2
  108. package/3.api/3.utils/define-lazy-hydration-component.md +13 -13
  109. package/3.api/3.utils/define-nuxt-component.md +5 -5
  110. package/3.api/3.utils/define-nuxt-plugin.md +12 -12
  111. package/3.api/3.utils/define-nuxt-route-middleware.md +2 -2
  112. package/3.api/3.utils/define-page-meta.md +16 -16
  113. package/3.api/3.utils/define-route-rules.md +5 -5
  114. package/3.api/3.utils/navigate-to.md +10 -10
  115. package/3.api/3.utils/preload-components.md +1 -1
  116. package/3.api/3.utils/preload-route-components.md +2 -2
  117. package/3.api/3.utils/prerender-routes.md +2 -2
  118. package/3.api/3.utils/refresh-cookie.md +4 -4
  119. package/3.api/3.utils/refresh-nuxt-data.md +10 -5
  120. package/3.api/3.utils/reload-nuxt-app.md +3 -3
  121. package/3.api/3.utils/set-response-status.md +2 -2
  122. package/3.api/3.utils/show-error.md +3 -3
  123. package/3.api/3.utils/update-app-config.md +3 -2
  124. package/3.api/4.commands/generate.md +1 -1
  125. package/3.api/4.commands/prepare.md +4 -0
  126. package/3.api/4.commands/typecheck.md +1 -1
  127. package/3.api/5.kit/1.modules.md +36 -36
  128. package/3.api/5.kit/10.templates.md +8 -6
  129. package/3.api/5.kit/11.nitro.md +62 -62
  130. package/3.api/5.kit/12.resolving.md +2 -2
  131. package/3.api/5.kit/14.builder.md +1 -0
  132. package/3.api/5.kit/15.examples.md +2 -2
  133. package/3.api/5.kit/16.layers.md +26 -26
  134. package/3.api/5.kit/3.compatibility.md +12 -12
  135. package/3.api/5.kit/4.autoimports.md +12 -12
  136. package/3.api/5.kit/5.components.md +5 -5
  137. package/3.api/5.kit/6.context.md +3 -3
  138. package/3.api/5.kit/7.pages.md +4 -4
  139. package/3.api/5.kit/8.layout.md +1 -1
  140. package/3.api/5.kit/9.plugins.md +5 -4
  141. package/3.api/6.advanced/1.hooks.md +1 -1
  142. package/3.api/6.advanced/2.import-meta.md +3 -3
  143. package/3.api/6.nuxt-config.md +299 -864
  144. package/3.api/index.md +7 -7
  145. package/5.community/4.contribution.md +5 -5
  146. package/5.community/5.framework-contribution.md +1 -1
  147. package/6.bridge/1.overview.md +1 -1
  148. package/6.bridge/10.configuration.md +2 -1
  149. package/6.bridge/2.typescript.md +2 -2
  150. package/6.bridge/3.bridge-composition-api.md +4 -4
  151. package/6.bridge/4.plugins-and-middleware.md +5 -5
  152. package/6.bridge/5.nuxt3-compatible-api.md +12 -9
  153. package/6.bridge/6.meta.md +15 -14
  154. package/6.bridge/8.nitro.md +2 -2
  155. package/6.bridge/9.vite.md +3 -3
  156. package/7.migration/10.bundling.md +1 -1
  157. package/7.migration/11.server.md +3 -3
  158. package/7.migration/2.configuration.md +18 -16
  159. package/7.migration/20.module-authors.md +1 -1
  160. package/7.migration/4.meta.md +18 -15
  161. package/7.migration/5.plugins-and-middleware.md +8 -8
  162. package/7.migration/6.pages-and-layouts.md +20 -16
  163. package/7.migration/7.component-options.md +7 -7
  164. package/7.migration/8.runtime-config.md +4 -4
  165. package/package.json +1 -1
@@ -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
  ```
@@ -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 -->
@@ -84,12 +84,12 @@ Alternatively, `pageKey` can be passed as a `key` value via [`definePageMeta`](/
84
84
  ```vue [app/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
  ```
91
91
 
92
- :link-example{to="/docs/examples/routing/pages"}
92
+ :link-example{to="/docs/4.x/examples/routing/pages"}
93
93
 
94
94
  ## Page's Ref
95
95
 
@@ -151,4 +151,4 @@ console.log(attrs.foobar) // Outputs: 123
151
151
  </script>
152
152
  ```
153
153
 
154
- :read-more{to="/docs/guide/directory-structure/app/pages"}
154
+ :read-more{to="/docs/4.x/guide/directory-structure/app/pages"}
@@ -18,7 +18,7 @@ You can use `<NuxtLayout />` component to activate the `default` layout on `app.
18
18
  </template>
19
19
  ```
20
20
 
21
- :read-more{to="/docs/guide/directory-structure/app/layouts"}
21
+ :read-more{to="/docs/4.x/guide/directory-structure/app/layouts"}
22
22
 
23
23
  ## Props
24
24
 
@@ -51,7 +51,7 @@ Please note the layout name is normalized to kebab-case, so if your layout file
51
51
  </template>
52
52
  ```
53
53
 
54
- ::read-more{to="/docs/guide/directory-structure/app/layouts"}
54
+ ::read-more{to="/docs/4.x/guide/directory-structure/app/layouts"}
55
55
  Read more about dynamic layouts.
56
56
  ::
57
57
 
@@ -66,8 +66,11 @@ Read more about dynamic layouts.
66
66
  ```vue [app/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>
@@ -111,7 +116,7 @@ console.log(layoutCustomProps.title) // I am a custom layout
111
116
 
112
117
  ::
113
118
 
114
- :read-more{to="/docs/getting-started/transitions"}
119
+ :read-more{to="/docs/4.x/getting-started/transitions"}
115
120
 
116
121
  ## Layout's Ref
117
122
 
@@ -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
 
@@ -153,4 +158,4 @@ defineExpose({
153
158
 
154
159
  ::
155
160
 
156
- :read-more{to="/docs/guide/directory-structure/app/layouts"}
161
+ :read-more{to="/docs/4.x/guide/directory-structure/app/layouts"}
@@ -67,7 +67,10 @@ For static files in the `/public` directory, such as PDFs or images, use the `ex
67
67
 
68
68
  ```vue [app/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 [app/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/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 [app/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
@@ -249,7 +269,7 @@ When not using `external`, `<NuxtLink>` supports all Vue Router's [`RouterLink`
249
269
  - `rel`: A `rel` attribute value to apply on the link. Defaults to `"noopener noreferrer"` for external links.
250
270
 
251
271
  ::tip
252
- Defaults can be overwritten, see [overwriting defaults](/docs/api/components/nuxt-link#overwriting-defaults) if you want to change them.
272
+ Defaults can be overwritten, see [overwriting defaults](/docs/4.x/api/components/nuxt-link#overwriting-defaults) if you want to change them.
253
273
  ::
254
274
 
255
275
  ## Overwriting Defaults
@@ -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 [app/components/MyNuxtLink.ts]
309
+ ```ts [app/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`.
@@ -323,4 +343,4 @@ function defineNuxtLink(options: NuxtLinkOptions): Component {}
323
343
  - `prefetchOn`: Granular control of which prefetch strategies to apply by default.
324
344
  - `prefetchedClass`: A default class to apply to links that have been prefetched.
325
345
 
326
- :link-example{to="/docs/examples/routing/pages"}
346
+ :link-example{to="/docs/4.x/examples/routing/pages"}
@@ -21,7 +21,7 @@ Add `<NuxtLoadingIndicator/>` in your [`app.vue`](/docs/4.x/guide/directory-stru
21
21
  </template>
22
22
  ```
23
23
 
24
- :link-example{to="/docs/examples/routing/pages"}
24
+ :link-example{to="/docs/4.x/examples/routing/pages"}
25
25
 
26
26
  ## Slots
27
27
 
@@ -29,19 +29,21 @@ 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
- :read-more{to="/docs/getting-started/error-handling"}
46
+ :read-more{to="/docs/4.x/getting-started/error-handling"}
45
47
 
46
48
  ## Examples
47
49
 
@@ -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
@@ -16,4 +16,4 @@ const appConfig = useAppConfig()
16
16
  console.log(appConfig)
17
17
  ```
18
18
 
19
- :read-more{to="/docs/guide/directory-structure/app-config"}
19
+ :read-more{to="/docs/4.x/guide/directory-structure/app-config"}
@@ -20,7 +20,7 @@ Within your pages, components, and plugins you can use useAsyncData to get acces
20
20
  <script setup lang="ts">
21
21
  const { data, status, error, refresh, clear } = await useAsyncData(
22
22
  'mountains',
23
- () => $fetch('https://api.nuxtjs.dev/mountains')
23
+ () => $fetch('https://api.nuxtjs.dev/mountains'),
24
24
  )
25
25
  </script>
26
26
  ```
@@ -44,11 +44,11 @@ const { data: posts } = await useAsyncData(
44
44
  'posts',
45
45
  () => $fetch('https://fakeApi.com/posts', {
46
46
  params: {
47
- page: page.value
48
- }
47
+ page: page.value,
48
+ },
49
49
  }), {
50
- watch: [page]
51
- }
50
+ watch: [page],
51
+ },
52
52
  )
53
53
  </script>
54
54
  ```
@@ -65,7 +65,7 @@ const userId = computed(() => `user-${route.params.id}`)
65
65
  // When the route changes and userId updates, the data will be automatically refetched
66
66
  const { data: user } = useAsyncData(
67
67
  userId,
68
- () => fetchUserById(route.params.id)
68
+ () => fetchUserById(route.params.id),
69
69
  )
70
70
  </script>
71
71
  ```
@@ -74,7 +74,7 @@ const { data: user } = useAsyncData(
74
74
  [`useAsyncData`](/docs/4.x/api/composables/use-async-data) is a reserved function name transformed by the compiler, so you should not name your own function [`useAsyncData`](/docs/4.x/api/composables/use-async-data).
75
75
  ::
76
76
 
77
- :read-more{to="/docs/getting-started/data-fetching#useasyncdata"}
77
+ :read-more{to="/docs/4.x/getting-started/data-fetching#useasyncdata"}
78
78
 
79
79
  ## Params
80
80
 
@@ -91,8 +91,8 @@ The `handler` function should be **side-effect free** to ensure predictable beha
91
91
  - `transform`: a function that can be used to alter `handler` function result after resolving
92
92
  - `getCachedData`: Provide a function which returns cached data. A `null` or `undefined` return value will trigger a fetch. By default, this is:
93
93
  ```ts
94
- const getDefaultCachedData = (key, nuxtApp, ctx) => nuxtApp.isHydrating
95
- ? nuxtApp.payload.data[key]
94
+ const getDefaultCachedData = (key, nuxtApp, ctx) => nuxtApp.isHydrating
95
+ ? nuxtApp.payload.data[key]
96
96
  : nuxtApp.static.data[key]
97
97
  ```
98
98
  Which only caches data when `experimental.payloadExtraction` of `nuxt.config` is enabled.
@@ -107,7 +107,7 @@ The `handler` function should be **side-effect free** to ensure predictable beha
107
107
  Under the hood, `lazy: false` uses `<Suspense>` to block the loading of the route before the data has been fetched. Consider using `lazy: true` and implementing a loading state instead for a snappier user experience.
108
108
  ::
109
109
 
110
- ::read-more{to="/docs/api/composables/use-lazy-async-data"}
110
+ ::read-more{to="/docs/4.x/api/composables/use-lazy-async-data"}
111
111
  You can use `useLazyAsyncData` to have the same behavior as `lazy: true` with `useAsyncData`.
112
112
  ::
113
113
 
@@ -169,11 +169,11 @@ If you have not fetched data on the server (for example, with `server: false`),
169
169
  ## Type
170
170
 
171
171
  ```ts [Signature]
172
- function useAsyncData<DataT, DataE>(
172
+ export function useAsyncData<DataT, DataE> (
173
173
  handler: (nuxtApp?: NuxtApp) => Promise<DataT>,
174
174
  options?: AsyncDataOptions<DataT>
175
175
  ): AsyncData<DataT, DataE>
176
- function useAsyncData<DataT, DataE>(
176
+ export function useAsyncData<DataT, DataE> (
177
177
  key: MaybeRefOrGetter<string>,
178
178
  handler: (nuxtApp?: NuxtApp) => Promise<DataT>,
179
179
  options?: AsyncDataOptions<DataT>
@@ -204,7 +204,7 @@ type AsyncData<DataT, ErrorT> = {
204
204
  clear: () => void
205
205
  error: Ref<ErrorT | undefined>
206
206
  status: Ref<AsyncDataRequestStatus>
207
- };
207
+ }
208
208
 
209
209
  interface AsyncDataExecuteOptions {
210
210
  dedupe?: 'cancel' | 'defer'
@@ -213,4 +213,4 @@ interface AsyncDataExecuteOptions {
213
213
  type AsyncDataRequestStatus = 'idle' | 'pending' | 'success' | 'error'
214
214
  ```
215
215
 
216
- :read-more{to="/docs/getting-started/data-fetching"}
216
+ :read-more{to="/docs/4.x/getting-started/data-fetching"}
@@ -40,7 +40,7 @@ export interface CookieOptions<T = any> extends Omit<CookieSerializeOptions & Co
40
40
 
41
41
  export interface CookieRef<T> extends Ref<T> {}
42
42
 
43
- export function useCookie<T = string | null | undefined>(
43
+ export function useCookie<T = string | null | undefined> (
44
44
  name: string,
45
45
  options?: CookieOptions<T>
46
46
  ): CookieRef<T>
@@ -84,15 +84,21 @@ The example below creates a cookie called `counter`. If the cookie doesn't exist
84
84
  <script setup lang="ts">
85
85
  const counter = useCookie('counter')
86
86
 
87
- counter.value = counter.value || Math.round(Math.random() * 1000)
87
+ counter.value ||= Math.round(Math.random() * 1000)
88
88
  </script>
89
89
 
90
90
  <template>
91
91
  <div>
92
92
  <h1>Counter: {{ counter || '-' }}</h1>
93
- <button @click="counter = null">reset</button>
94
- <button @click="counter--">-</button>
95
- <button @click="counter++">+</button>
93
+ <button @click="counter = null">
94
+ reset
95
+ </button>
96
+ <button @click="counter--">
97
+ -
98
+ </button>
99
+ <button @click="counter++">
100
+ +
101
+ </button>
96
102
  </div>
97
103
  </template>
98
104
  ```
@@ -105,8 +111,8 @@ const user = useCookie(
105
111
  'userInfo',
106
112
  {
107
113
  default: () => ({ score: -1 }),
108
- watch: false
109
- }
114
+ watch: false,
115
+ },
110
116
  )
111
117
 
112
118
  if (user.value) {
@@ -128,20 +134,18 @@ const list = useCookie(
128
134
  'list',
129
135
  {
130
136
  default: () => [],
131
- watch: 'shallow'
132
- }
137
+ watch: 'shallow',
138
+ },
133
139
  )
134
140
 
135
- function add() {
141
+ function add () {
136
142
  list.value?.push(Math.round(Math.random() * 1000))
137
143
  // list cookie won't be updated with this change
138
144
  }
139
145
 
140
- function save() {
141
- if (list.value) {
142
- // the actual `list` cookie will be updated
143
- list.value = [...list.value]
144
- }
146
+ function save () {
147
+ // the actual `list` cookie will be updated
148
+ list.value &&= [...list.value]
145
149
  }
146
150
  </script>
147
151
 
@@ -149,8 +153,12 @@ function save() {
149
153
  <div>
150
154
  <h1>List</h1>
151
155
  <pre>{{ list }}</pre>
152
- <button @click="add">Add</button>
153
- <button @click="save">Save</button>
156
+ <button @click="add">
157
+ Add
158
+ </button>
159
+ <button @click="save">
160
+ Save
161
+ </button>
154
162
  </div>
155
163
  </template>
156
164
  ```
@@ -160,7 +168,7 @@ function save() {
160
168
  You can use `getCookie` and `setCookie` from [`h3`](https://github.com/h3js/h3) package to set cookies in server API routes.
161
169
 
162
170
  ```ts [server/api/counter.ts]
163
- export default defineEventHandler(event => {
171
+ export default defineEventHandler((event) => {
164
172
  // Read counter cookie
165
173
  let counter = getCookie(event, 'counter') || 0
166
174
 
@@ -172,4 +180,4 @@ export default defineEventHandler(event => {
172
180
  })
173
181
  ```
174
182
 
175
- :link-example{to="/docs/examples/advanced/use-cookie"}
183
+ :link-example{to="/docs/4.x/examples/advanced/use-cookie"}
@@ -42,7 +42,7 @@ Returns a `Ref` containing the current Nuxt error (or `undefined` if there is no
42
42
 
43
43
  ## Example
44
44
 
45
- ```ts
45
+ ```vue
46
46
  <script setup lang="ts">
47
47
  const error = useError()
48
48
 
@@ -52,4 +52,4 @@ if (error.value) {
52
52
  </script>
53
53
  ```
54
54
 
55
- :read-more{to="/docs/getting-started/error-handling"}
55
+ :read-more{to="/docs/4.x/getting-started/error-handling"}