@nuxt/docs 3.20.2 → 3.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/1.getting-started/01.introduction.md +4 -4
  2. package/1.getting-started/02.installation.md +4 -7
  3. package/1.getting-started/03.configuration.md +29 -29
  4. package/1.getting-started/04.views.md +6 -4
  5. package/1.getting-started/05.assets.md +2 -2
  6. package/1.getting-started/06.styling.md +22 -16
  7. package/1.getting-started/07.routing.md +6 -6
  8. package/1.getting-started/08.seo-meta.md +8 -4
  9. package/1.getting-started/09.transitions.md +6 -6
  10. package/1.getting-started/10.data-fetching.md +18 -18
  11. package/1.getting-started/11.state-management.md +5 -5
  12. package/1.getting-started/12.error-handling.md +25 -19
  13. package/1.getting-started/13.server.md +9 -9
  14. package/1.getting-started/14.layers.md +49 -15
  15. package/1.getting-started/15.prerendering.md +10 -4
  16. package/1.getting-started/16.deployment.md +2 -1
  17. package/1.getting-started/17.testing.md +17 -7
  18. package/1.getting-started/18.upgrade.md +111 -60
  19. package/2.directory-structure/0.output.md +1 -1
  20. package/2.directory-structure/1.assets.md +1 -1
  21. package/2.directory-structure/1.components.md +12 -8
  22. package/2.directory-structure/1.composables.md +2 -2
  23. package/2.directory-structure/1.content.md +1 -1
  24. package/2.directory-structure/1.layers.md +87 -0
  25. package/2.directory-structure/1.layouts.md +35 -3
  26. package/2.directory-structure/1.middleware.md +7 -7
  27. package/2.directory-structure/1.modules.md +8 -2
  28. package/2.directory-structure/1.node_modules.md +1 -1
  29. package/2.directory-structure/1.pages.md +39 -18
  30. package/2.directory-structure/1.plugins.md +4 -1
  31. package/2.directory-structure/1.public.md +1 -1
  32. package/2.directory-structure/1.server.md +28 -8
  33. package/2.directory-structure/1.shared.md +3 -3
  34. package/2.directory-structure/1.utils.md +2 -2
  35. package/2.directory-structure/2.env.md +3 -3
  36. package/2.directory-structure/2.nuxtignore.md +1 -0
  37. package/2.directory-structure/2.nuxtrc.md +5 -2
  38. package/2.directory-structure/3.app-config.md +2 -2
  39. package/2.directory-structure/3.app.md +3 -3
  40. package/2.directory-structure/3.error.md +9 -5
  41. package/2.directory-structure/3.nuxt-config.md +1 -1
  42. package/2.directory-structure/3.package.md +1 -1
  43. package/2.directory-structure/3.tsconfig.md +3 -2
  44. package/2.directory-structure/index.md +12 -8
  45. package/3.guide/0.index.md +8 -2
  46. package/3.guide/1.concepts/{3.rendering.md → 1.rendering.md} +7 -32
  47. package/3.guide/1.concepts/{2.vuejs-development.md → 10.vuejs-development.md} +9 -8
  48. package/3.guide/1.concepts/{10.nuxt-lifecycle.md → 2.nuxt-lifecycle.md} +31 -24
  49. package/3.guide/1.concepts/{1.auto-imports.md → 3.auto-imports.md} +6 -6
  50. package/3.guide/1.concepts/4.server-engine.md +2 -2
  51. package/3.guide/1.concepts/5.modules.md +14 -1
  52. package/3.guide/1.concepts/7.esm.md +5 -4
  53. package/3.guide/1.concepts/8.typescript.md +9 -15
  54. package/3.guide/1.concepts/9.code-style.md +1 -1
  55. package/3.guide/2.best-practices/hydration.md +1 -1
  56. package/3.guide/2.best-practices/performance.md +5 -5
  57. package/3.guide/3.ai/.navigation.yml +3 -0
  58. package/3.guide/3.ai/1.mcp.md +277 -0
  59. package/3.guide/3.ai/2.llms-txt.md +65 -0
  60. package/3.guide/4.modules/.navigation.yml +3 -0
  61. package/3.guide/4.modules/1.getting-started.md +103 -0
  62. package/3.guide/4.modules/2.module-anatomy.md +138 -0
  63. package/3.guide/4.modules/3.recipes-basics.md +330 -0
  64. package/3.guide/4.modules/4.recipes-advanced.md +243 -0
  65. package/3.guide/4.modules/5.testing.md +76 -0
  66. package/3.guide/4.modules/6.best-practices.md +104 -0
  67. package/3.guide/4.modules/7.ecosystem.md +32 -0
  68. package/3.guide/4.modules/index.md +36 -0
  69. package/3.guide/{3.recipes → 5.recipes}/1.custom-routing.md +3 -3
  70. package/3.guide/{3.recipes → 5.recipes}/2.vite-plugin.md +4 -0
  71. package/3.guide/{3.recipes → 5.recipes}/3.custom-usefetch.md +2 -2
  72. package/3.guide/{3.recipes → 5.recipes}/4.sessions-and-authentication.md +2 -2
  73. package/3.guide/{4.going-further → 6.going-further}/1.events.md +3 -4
  74. package/3.guide/{4.going-further → 6.going-further}/1.experimental-features.md +211 -86
  75. package/3.guide/6.going-further/1.features.md +108 -0
  76. package/3.guide/{4.going-further → 6.going-further}/1.internals.md +4 -3
  77. package/3.guide/{4.going-further → 6.going-further}/10.runtime-config.md +2 -2
  78. package/3.guide/{4.going-further → 6.going-further}/11.nightly-release-channel.md +1 -1
  79. package/3.guide/{4.going-further → 6.going-further}/2.hooks.md +5 -5
  80. package/3.guide/{4.going-further → 6.going-further}/4.kit.md +3 -3
  81. package/3.guide/{4.going-further → 6.going-further}/6.nuxt-app.md +6 -6
  82. package/3.guide/{4.going-further → 6.going-further}/7.layers.md +31 -5
  83. package/3.guide/{4.going-further → 6.going-further}/9.debugging.md +3 -2
  84. package/4.api/1.components/1.nuxt-client-fallback.md +5 -1
  85. package/4.api/1.components/10.nuxt-picture.md +1 -1
  86. package/4.api/1.components/11.teleports.md +2 -2
  87. package/4.api/1.components/12.nuxt-route-announcer.md +0 -2
  88. package/4.api/1.components/13.nuxt-time.md +0 -2
  89. package/4.api/1.components/2.nuxt-page.md +3 -3
  90. package/4.api/1.components/3.nuxt-layout.md +6 -6
  91. package/4.api/1.components/4.nuxt-link.md +13 -13
  92. package/4.api/1.components/5.nuxt-loading-indicator.md +1 -1
  93. package/4.api/1.components/6.nuxt-error-boundary.md +2 -2
  94. package/4.api/1.components/7.nuxt-welcome.md +2 -2
  95. package/4.api/1.components/8.nuxt-island.md +9 -2
  96. package/4.api/2.composables/use-app-config.md +1 -1
  97. package/4.api/2.composables/use-async-data.md +5 -5
  98. package/4.api/2.composables/use-cookie.md +16 -16
  99. package/4.api/2.composables/use-error.md +3 -3
  100. package/4.api/2.composables/use-fetch.md +37 -37
  101. package/4.api/2.composables/use-head-safe.md +1 -1
  102. package/4.api/2.composables/use-head.md +22 -7
  103. package/4.api/2.composables/use-lazy-async-data.md +1 -1
  104. package/4.api/2.composables/use-lazy-fetch.md +9 -9
  105. package/4.api/2.composables/use-nuxt-app.md +9 -7
  106. package/4.api/2.composables/use-route-announcer.md +0 -2
  107. package/4.api/2.composables/use-route.md +2 -2
  108. package/4.api/2.composables/use-router.md +15 -15
  109. package/4.api/2.composables/use-runtime-config.md +5 -5
  110. package/4.api/2.composables/use-seo-meta.md +2 -2
  111. package/4.api/2.composables/use-server-seo-meta.md +2 -2
  112. package/4.api/2.composables/use-state.md +12 -2
  113. package/4.api/3.utils/$fetch.md +1 -1
  114. package/4.api/3.utils/abort-navigation.md +2 -2
  115. package/4.api/3.utils/call-once.md +2 -4
  116. package/4.api/3.utils/clear-error.md +1 -1
  117. package/4.api/3.utils/create-error.md +7 -7
  118. package/4.api/3.utils/define-lazy-hydration-component.md +5 -5
  119. package/4.api/3.utils/define-nuxt-component.md +1 -1
  120. package/4.api/3.utils/define-nuxt-plugin.md +12 -12
  121. package/4.api/3.utils/define-nuxt-route-middleware.md +2 -2
  122. package/4.api/3.utils/define-page-meta.md +18 -11
  123. package/4.api/3.utils/define-route-rules.md +2 -2
  124. package/4.api/3.utils/navigate-to.md +14 -14
  125. package/4.api/3.utils/on-before-route-leave.md +1 -1
  126. package/4.api/3.utils/on-before-route-update.md +1 -1
  127. package/4.api/3.utils/preload-route-components.md +2 -2
  128. package/4.api/3.utils/refresh-cookie.md +0 -2
  129. package/4.api/3.utils/refresh-nuxt-data.md +1 -1
  130. package/4.api/3.utils/reload-nuxt-app.md +1 -1
  131. package/4.api/3.utils/set-page-layout.md +36 -0
  132. package/4.api/3.utils/set-response-status.md +3 -3
  133. package/4.api/3.utils/show-error.md +4 -4
  134. package/4.api/3.utils/update-app-config.md +1 -1
  135. package/4.api/4.commands/add.md +11 -11
  136. package/4.api/4.commands/analyze.md +11 -11
  137. package/4.api/4.commands/build-module.md +11 -11
  138. package/4.api/4.commands/build.md +12 -12
  139. package/4.api/4.commands/cleanup.md +6 -6
  140. package/4.api/4.commands/dev.md +23 -23
  141. package/4.api/4.commands/devtools.md +7 -7
  142. package/4.api/4.commands/generate.md +12 -12
  143. package/4.api/4.commands/info.md +6 -6
  144. package/4.api/4.commands/init.md +18 -18
  145. package/4.api/4.commands/module.md +18 -18
  146. package/4.api/4.commands/prepare.md +10 -10
  147. package/4.api/4.commands/preview.md +11 -11
  148. package/4.api/4.commands/test.md +9 -9
  149. package/4.api/4.commands/typecheck.md +10 -10
  150. package/4.api/4.commands/upgrade.md +10 -10
  151. package/4.api/5.kit/1.modules.md +31 -18
  152. package/4.api/5.kit/10.templates.md +23 -23
  153. package/4.api/5.kit/11.nitro.md +36 -36
  154. package/4.api/5.kit/12.resolving.md +2 -2
  155. package/4.api/5.kit/14.builder.md +35 -23
  156. package/4.api/5.kit/16.layers.md +16 -16
  157. package/4.api/5.kit/2.programmatic.md +2 -2
  158. package/4.api/5.kit/3.compatibility.md +2 -2
  159. package/4.api/5.kit/4.autoimports.md +18 -18
  160. package/4.api/5.kit/5.components.md +35 -35
  161. package/4.api/5.kit/6.context.md +1 -1
  162. package/4.api/5.kit/8.layout.md +1 -1
  163. package/4.api/6.advanced/1.hooks.md +85 -85
  164. package/4.api/index.md +7 -7
  165. package/5.community/4.contribution.md +10 -10
  166. package/5.community/5.framework-contribution.md +9 -9
  167. package/5.community/6.roadmap.md +25 -25
  168. package/5.community/7.changelog.md +10 -0
  169. package/6.bridge/1.overview.md +8 -0
  170. package/6.bridge/3.bridge-composition-api.md +2 -2
  171. package/6.bridge/4.plugins-and-middleware.md +2 -2
  172. package/6.bridge/5.nuxt3-compatible-api.md +1 -1
  173. package/6.bridge/8.nitro.md +4 -0
  174. package/7.migration/10.bundling.md +1 -1
  175. package/7.migration/11.server.md +3 -3
  176. package/7.migration/2.configuration.md +5 -5
  177. package/7.migration/20.module-authors.md +3 -3
  178. package/7.migration/4.meta.md +1 -1
  179. package/7.migration/5.plugins-and-middleware.md +3 -3
  180. package/7.migration/6.pages-and-layouts.md +5 -5
  181. package/7.migration/7.component-options.md +6 -6
  182. package/7.migration/8.runtime-config.md +1 -1
  183. package/package.json +1 -1
  184. package/3.guide/4.going-further/1.features.md +0 -103
  185. package/3.guide/4.going-further/3.modules.md +0 -901
  186. /package/3.guide/{3.recipes → 5.recipes}/.navigation.yml +0 -0
  187. /package/3.guide/{4.going-further → 6.going-further}/.navigation.yml +0 -0
  188. /package/3.guide/{4.going-further → 6.going-further}/index.md +0 -0
@@ -25,8 +25,8 @@ const { data, status, error, refresh, clear } = await useFetch('/api/modules', {
25
25
  </script>
26
26
  ```
27
27
 
28
- ::warning
29
- If you're using a custom useFetch wrapper, do not await it in the composable, as that can cause unexpected behavior. Please follow [this recipe](/docs/3.x/guide/recipes/custom-usefetch#custom-usefetch) for more information on how to make a custom async data fetcher.
28
+ ::warning{to="/docs/3.x/guide/recipes/custom-usefetch#custom-usefetchuseasyncdata"}
29
+ If you're using a custom `useFetch` wrapper, do not await it in the composable as that can cause unexpected behavior. See recipe for custom async data fetcher.
30
30
  ::
31
31
 
32
32
  ::note
@@ -96,11 +96,11 @@ If you encounter the `data` variable destructured from a `useFetch` returns a st
96
96
 
97
97
  :video-accordion{title="Watch the video from Alexander Lichter to avoid using useFetch the wrong way" videoId="njsGVmcWviY"}
98
98
 
99
- :read-more{to="/docs/getting-started/data-fetching"}
99
+ :read-more{to="/docs/3.x/getting-started/data-fetching"}
100
100
 
101
101
  ### Reactive Fetch Options
102
102
 
103
- Fetch options can be provided as reactive, supporting `computed`, `ref` and [computed getters](https://vuejs.org/guide/essentials/computed.html). When a reactive fetch option is updated it will trigger a refetch using the updated resolved reactive value.
103
+ Fetch options can be provided as reactive, supporting `computed`, `ref` and [computed getters](https://vuejs.org/guide/essentials/computed). When a reactive fetch option is updated it will trigger a refetch using the updated resolved reactive value.
104
104
 
105
105
  ```ts
106
106
  const searchQuery = ref('initial')
@@ -183,29 +183,29 @@ type AsyncDataRequestStatus = 'idle' | 'pending' | 'success' | 'error'
183
183
 
184
184
  - `options` (object): Configuration for the fetch request. Extends [unjs/ofetch](https://github.com/unjs/ofetch) options and [`AsyncDataOptions`](/docs/3.x/api/composables/use-async-data#params). All options can be a static value, a `ref`, or a computed value.
185
185
 
186
- | Option | Type | Default | Description |
187
- | ---| --- | --- | --- |
188
- | `key` | `MaybeRefOrGetter<string>` | auto-gen | Unique key for de-duplication. If not provided, generated from URL and options. |
189
- | `method` | `MaybeRefOrGetter<string>` | `'GET'` | HTTP request method. |
190
- | `query` | `MaybeRefOrGetter<SearchParams>` | - | Query/search params to append to the URL. Alias: `params`. |
191
- | `params` | `MaybeRefOrGetter<SearchParams>` | - | Alias for `query`. |
192
- | `body` | `MaybeRefOrGetter<RequestInit['body'] \| Record<string, any>>` | - | Request body. Objects are automatically stringified. |
193
- | `headers` | `MaybeRefOrGetter<Record<string, string> \| [key, value][] \| Headers>` | - | Request headers. |
194
- | `baseURL` | `MaybeRefOrGetter<string>` | - | Base URL for the request. |
195
- | `timeout` | `MaybeRefOrGetter<number>` | - | Timeout in milliseconds to abort the request. |
196
- | `cache` | `boolean \| string` | - | Cache control. Boolean disables cache, or use Fetch API values: `default`, `no-store`, etc. |
197
- | `server` | `boolean` | `true` | Whether to fetch on the server. |
198
- | `lazy` | `boolean` | `false` | If true, resolves after route loads (does not block navigation). |
199
- | `immediate` | `boolean` | `true` | If false, prevents request from firing immediately. |
200
- | `default` | `() => DataT` | - | Factory for default value of `data` before async resolves. |
201
- | `timeout` | `number` | - | A number in milliseconds to wait before timing out the request (defaults to `undefined`, which means no timeout) |
202
- | `transform` | `(input: DataT) => DataT \| Promise<DataT>` | - | Function to transform the result after resolving. |
203
- | `getCachedData`| `(key, nuxtApp, ctx) => DataT \| undefined` | - | Function to return cached data. See below for default. |
204
- | `pick` | `string[]` | - | Only pick specified keys from the result. |
205
- | `watch` | `MultiWatchSources \| false` | - | Array of reactive sources to watch and auto-refresh. `false` disables watching. |
206
- | `deep` | `boolean` | `true` | Return data in a deep ref object. Set to `false` to return data in a shallow ref object, which can improve performance if your data does not need to be deeply reactive. |
207
- | `dedupe` | `'cancel' \| 'defer'` | `'cancel'` | Avoid fetching same key more than once at a time. |
208
- | `$fetch` | `typeof globalThis.$fetch` | - | Custom $fetch implementation. See [Custom useFetch in Nuxt](/docs/guide/recipes/custom-usefetch) |
186
+ | Option | Type | Default | Description |
187
+ |-----------------|-------------------------------------------------------------------------|------------|------------------------------------------------------------------------------------------------------------------|
188
+ | `key` | `MaybeRefOrGetter<string>` | auto-gen | Unique key for de-duplication. If not provided, generated from URL and options. |
189
+ | `method` | `MaybeRefOrGetter<string>` | `'GET'` | HTTP request method. |
190
+ | `query` | `MaybeRefOrGetter<SearchParams>` | - | Query/search params to append to the URL. Alias: `params`. |
191
+ | `params` | `MaybeRefOrGetter<SearchParams>` | - | Alias for `query`. |
192
+ | `body` | `MaybeRefOrGetter<RequestInit['body'] \| Record<string, any>>` | - | Request body. Objects are automatically stringified. |
193
+ | `headers` | `MaybeRefOrGetter<Record<string, string> \| [key, value][] \| Headers>` | - | Request headers. |
194
+ | `baseURL` | `MaybeRefOrGetter<string>` | - | Base URL for the request. |
195
+ | `timeout` | `MaybeRefOrGetter<number>` | - | Timeout in milliseconds to abort the request. |
196
+ | `cache` | `boolean \| string` | - | Cache control. Boolean disables cache, or use Fetch API values: `default`, `no-store`, etc. |
197
+ | `server` | `boolean` | `true` | Whether to fetch on the server. |
198
+ | `lazy` | `boolean` | `false` | If true, resolves after route loads (does not block navigation). |
199
+ | `immediate` | `boolean` | `true` | If false, prevents request from firing immediately. |
200
+ | `default` | `() => DataT` | - | Factory for default value of `data` before async resolves. |
201
+ | `timeout` | `number` | - | A number in milliseconds to wait before timing out the request (defaults to `undefined`, which means no timeout) |
202
+ | `transform` | `(input: DataT) => DataT \| Promise<DataT>` | - | Function to transform the result after resolving. |
203
+ | `getCachedData` | `(key, nuxtApp, ctx) => DataT \| undefined` | - | Function to return cached data. See below for default. |
204
+ | `pick` | `string[]` | - | Only pick specified keys from the result. |
205
+ | `watch` | `MultiWatchSources \| false` | - | Array of reactive sources to watch and auto-refresh. `false` disables watching. |
206
+ | `deep` | `boolean` | `false` | Return data in a deep ref object. |
207
+ | `dedupe` | `'cancel' \| 'defer'` | `'cancel'` | Avoid fetching same key more than once at a time. |
208
+ | `$fetch` | `typeof globalThis.$fetch` | - | Custom $fetch implementation. See [Custom useFetch in Nuxt](/docs/3.x/guide/recipes/custom-usefetch) |
209
209
 
210
210
  ::note
211
211
  All fetch options can be given a `computed` or `ref` value. These will be watched and new requests made automatically with any new values if they are updated.
@@ -222,14 +222,14 @@ This only caches data when `experimental.payloadExtraction` in `nuxt.config` is
222
222
 
223
223
  ## Return Values
224
224
 
225
- | Name | Type | Description |
226
- | --- | --- |--- |
227
- | `data` | `Ref<DataT \| undefined>` | The result of the asynchronous fetch. |
228
- | `refresh` | `(opts?: AsyncDataExecuteOptions) => Promise<void>` | Function to manually refresh the data. By default, Nuxt waits until a `refresh` is finished before it can be executed again. |
229
- | `execute` | `(opts?: AsyncDataExecuteOptions) => Promise<void>` | Alias for `refresh`. |
230
- | `error` | `Ref<ErrorT \| undefined>` | Error object if the data fetching failed. |
231
- | `status` | `Ref<'idle' \| 'pending' \| 'success' \| 'error'>` | Status of the data request. See below for possible values. |
232
- | `clear` | `() => void` | Resets `data` to `undefined` (or the value of `options.default()` if provided), `error` to `null`, set `status` to `idle`, and cancels any pending requests. |
225
+ | Name | Type | Description |
226
+ |-----------|-----------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|
227
+ | `data` | `Ref<DataT \| undefined>` | The result of the asynchronous fetch. |
228
+ | `refresh` | `(opts?: AsyncDataExecuteOptions) => Promise<void>` | Function to manually refresh the data. By default, Nuxt waits until a `refresh` is finished before it can be executed again. |
229
+ | `execute` | `(opts?: AsyncDataExecuteOptions) => Promise<void>` | Alias for `refresh`. |
230
+ | `error` | `Ref<ErrorT \| undefined>` | Error object if the data fetching failed. |
231
+ | `status` | `Ref<'idle' \| 'pending' \| 'success' \| 'error'>` | Status of the data request. See below for possible values. |
232
+ | `clear` | `() => void` | Resets `data` to `undefined` (or the value of `options.default()` if provided), `error` to `undefined`, set `status` to `idle`, and cancels any pending requests. |
233
233
 
234
234
  ### Status values
235
235
 
@@ -244,6 +244,6 @@ If you have not fetched data on the server (for example, with `server: false`),
244
244
 
245
245
  ### Examples
246
246
 
247
- :link-example{to="/docs/examples/advanced/use-custom-fetch-composable"}
247
+ :link-example{to="/docs/3.x/examples/advanced/use-custom-fetch-composable"}
248
248
 
249
- :link-example{to="/docs/examples/features/data-fetching"}
249
+ :link-example{to="/docs/3.x/examples/features/data-fetching"}
@@ -50,7 +50,7 @@ This composable does not return any value.
50
50
 
51
51
  ## Example
52
52
 
53
- ```vue [app/pages/user-profile.vue]
53
+ ```vue [pages/user-profile.vue]
54
54
  <script setup lang="ts">
55
55
  // User-generated content that might contain malicious code
56
56
  const userBio = ref('<script>alert("xss")<' + '/script>')
@@ -12,7 +12,7 @@ links:
12
12
 
13
13
  The `useHead` composable allows you to manage your head tags in a programmatic and reactive way, powered by [Unhead](https://unhead.unjs.io). It lets you customize the meta tags, links, scripts, and other elements in the `<head>` section of your HTML document.
14
14
 
15
- ```vue [app/app.vue]
15
+ ```vue [app.vue]
16
16
  <script setup lang="ts">
17
17
  useHead({
18
18
  title: 'My App',
@@ -38,7 +38,7 @@ The properties of `useHead` can be dynamic, accepting `ref`, `computed` and `rea
38
38
  ## Type
39
39
 
40
40
  ```ts [Signature]
41
- export function useHead (meta: MaybeComputedRef<MetaObject>): void
41
+ export function useHead (meta: MaybeComputedRef<MetaObject>): ActiveHeadEntry<UseHeadInput>
42
42
 
43
43
  interface MetaObject {
44
44
  title?: string
@@ -52,6 +52,21 @@ interface MetaObject {
52
52
  htmlAttrs?: HtmlAttributes
53
53
  bodyAttrs?: BodyAttributes
54
54
  }
55
+
56
+ interface ActiveHeadEntry<Input> {
57
+ /**
58
+ * Updates the entry with new input.
59
+ *
60
+ * Will first clear any side effects for previous input.
61
+ */
62
+ patch: (input: Input) => void
63
+ /**
64
+ * Dispose the entry, removing it from the active head.
65
+ *
66
+ * Will queue side effects for removal.
67
+ */
68
+ dispose: () => void
69
+ }
55
70
  ```
56
71
 
57
72
  See [@unhead/schema](https://github.com/unjs/unhead/blob/main/packages/vue/src/types/schema.ts) for more detailed types.
@@ -81,7 +96,7 @@ This composable does not return any value. It registers the head metadata with U
81
96
 
82
97
  ### Basic Meta Tags
83
98
 
84
- ```vue [app/pages/about.vue]
99
+ ```vue [pages/about.vue]
85
100
  <script setup lang="ts">
86
101
  useHead({
87
102
  title: 'About Us',
@@ -96,7 +111,7 @@ useHead({
96
111
 
97
112
  ### Reactive Meta Tags
98
113
 
99
- ```vue [app/pages/profile.vue]
114
+ ```vue [pages/profile.vue]
100
115
  <script setup lang="ts">
101
116
  const profile = ref({ name: 'John Doe' })
102
117
 
@@ -114,7 +129,7 @@ useHead({
114
129
 
115
130
  ### Using a Function for Full Reactivity
116
131
 
117
- ```vue [app/pages/dynamic.vue]
132
+ ```vue [pages/dynamic.vue]
118
133
  <script setup lang="ts">
119
134
  const count = ref(0)
120
135
 
@@ -129,7 +144,7 @@ useHead(() => ({
129
144
 
130
145
  ### Adding External Scripts and Styles
131
146
 
132
- ```vue [app/pages/external.vue]
147
+ ```vue [pages/external.vue]
133
148
  <script setup lang="ts">
134
149
  useHead({
135
150
  link: [
@@ -150,7 +165,7 @@ useHead({
150
165
 
151
166
  ### Body and HTML Attributes
152
167
 
153
- ```vue [app/pages/themed.vue]
168
+ ```vue [pages/themed.vue]
154
169
  <script setup lang="ts">
155
170
  const isDark = ref(true)
156
171
 
@@ -16,7 +16,7 @@ By default, [`useAsyncData`](/docs/3.x/api/composables/use-async-data) blocks na
16
16
 
17
17
  ## Usage
18
18
 
19
- ```vue [app/pages/index.vue]
19
+ ```vue [pages/index.vue]
20
20
  <script setup lang="ts">
21
21
  const { status, data: posts } = await useLazyAsyncData('posts', () => $fetch('/api/posts'))
22
22
  </script>
@@ -14,7 +14,7 @@ links:
14
14
 
15
15
  By default, [`useFetch`](/docs/3.x/api/composables/use-fetch) blocks navigation until its async handler is resolved. `useLazyFetch` allows navigation to proceed immediately, with data being fetched in the background.
16
16
 
17
- ```vue [app/pages/index.vue]
17
+ ```vue [pages/index.vue]
18
18
  <script setup lang="ts">
19
19
  const { status, data: posts } = await useLazyFetch('/api/posts')
20
20
  </script>
@@ -69,14 +69,14 @@ export function useLazyFetch<DataT, ErrorT> (
69
69
 
70
70
  Returns the same `AsyncData` object as [`useFetch`](/docs/3.x/api/composables/use-fetch):
71
71
 
72
- | Name | Type | Description |
73
- | --- | --- |--- |
74
- | `data` | `Ref<DataT \| undefined>` | The result of the asynchronous fetch. |
75
- | `refresh` | `(opts?: AsyncDataExecuteOptions) => Promise<void>` | Function to manually refresh the data. |
76
- | `execute` | `(opts?: AsyncDataExecuteOptions) => Promise<void>` | Alias for `refresh`. |
77
- | `error` | `Ref<ErrorT \| undefined>` | Error object if the data fetching failed. |
78
- | `status` | `Ref<'idle' \| 'pending' \| 'success' \| 'error'>` | Status of the data request. |
79
- | `clear` | `() => void` | Resets `data` to `undefined`, `error` to `undefined`, sets `status` to `idle`, and cancels any pending requests. |
72
+ | Name | Type | Description |
73
+ |-----------|-----------------------------------------------------|------------------------------------------------------------------------------------------------------------------|
74
+ | `data` | `Ref<DataT \| undefined>` | The result of the asynchronous fetch. |
75
+ | `refresh` | `(opts?: AsyncDataExecuteOptions) => Promise<void>` | Function to manually refresh the data. |
76
+ | `execute` | `(opts?: AsyncDataExecuteOptions) => Promise<void>` | Alias for `refresh`. |
77
+ | `error` | `Ref<ErrorT \| undefined>` | Error object if the data fetching failed. |
78
+ | `status` | `Ref<'idle' \| 'pending' \| 'success' \| 'error'>` | Status of the data request. |
79
+ | `clear` | `() => void` | Resets `data` to `undefined`, `error` to `undefined`, sets `status` to `idle`, and cancels any pending requests. |
80
80
 
81
81
  :read-more{to="/docs/3.x/api/composables/use-fetch#return-values"}
82
82
 
@@ -16,7 +16,7 @@ const nuxtApp = useNuxtApp()
16
16
  </script>
17
17
  ```
18
18
 
19
- If runtime context is unavailable in your scope, `useNuxtApp` will throw an exception when called. You can use [`tryUseNuxtApp`](#tryusenuxtapp) instead for composables that do not require `nuxtApp`, or to simply check if context is available or not without an exception.
19
+ If runtime context is unavailable in your scope, `useNuxtApp` will throw an exception when called. You can use [`tryUseNuxtApp`](/docs/3.x/api/composables/use-nuxt-app#tryusenuxtapp) instead for composables that do not require `nuxtApp`, or to simply check if context is available or not without an exception.
20
20
 
21
21
  <!--
22
22
  note
@@ -80,12 +80,12 @@ await nuxtApp.callHook('my-plugin:init')
80
80
 
81
81
  ### `vueApp`
82
82
 
83
- `vueApp` is the global Vue.js [application instance](https://vuejs.org/api/application.html#application-api) that you can access through `nuxtApp`.
83
+ `vueApp` is the global Vue.js [application instance](https://vuejs.org/api/application#application-api) that you can access through `nuxtApp`.
84
84
 
85
85
  Some useful methods:
86
- - [`component()`](https://vuejs.org/api/application.html#app-component) - Registers a global component if passing both a name string and a component definition, or retrieves an already registered one if only the name is passed.
87
- - [`directive()`](https://vuejs.org/api/application.html#app-directive) - Registers a global custom directive if passing both a name string and a directive definition, or retrieves an already registered one if only the name is passed[(example)](/docs/3.x/directory-structure/plugins#vue-directives).
88
- - [`use()`](https://vuejs.org/api/application.html#app-use) - Installs a **[Vue.js Plugin](https://vuejs.org/guide/reusability/plugins.html)** [(example)](/docs/3.x/directory-structure/plugins#vue-plugins).
86
+ - [`component()`](https://vuejs.org/api/application#app-component) - Registers a global component if passing both a name string and a component definition, or retrieves an already registered one if only the name is passed.
87
+ - [`directive()`](https://vuejs.org/api/application#app-directive) - Registers a global custom directive if passing both a name string and a directive definition, or retrieves an already registered one if only the name is passed[(example)](/docs/3.x/directory-structure/plugins#vue-directives).
88
+ - [`use()`](https://vuejs.org/api/application#app-use) - Installs a **[Vue.js Plugin](https://vuejs.org/guide/reusability/plugins)** [(example)](/docs/3.x/directory-structure/plugins#vue-plugins).
89
89
 
90
90
  :read-more{icon="i-simple-icons-vuedotjs" to="https://vuejs.org/api/application.html#application-api"}
91
91
 
@@ -120,7 +120,7 @@ Nuxt exposes the following properties through `ssrContext`:
120
120
 
121
121
  After fetching the value of `count` using [`useAsyncData`](/docs/3.x/api/composables/use-async-data) in the example above, if you access `payload.data`, you will see `{ count: 1 }` recorded there.
122
122
 
123
- When accessing the same `payload.data` from [`ssrcontext`](#ssrcontext), you can access the same value on the server side as well.
123
+ When accessing the same `payload.data` from [`ssrcontext`](/docs/3.x/api/composables/use-nuxt-app#ssrcontext), you can access the same value on the server side as well.
124
124
 
125
125
  - `state` (object) - When you use [`useState`](/docs/3.x/api/composables/use-state) composable in Nuxt to set shared state, this state data is accessed through `payload.state.[name-of-your-state]`.
126
126
 
@@ -136,6 +136,8 @@ Nuxt exposes the following properties through `ssrContext`:
136
136
 
137
137
  It is also possible to use more advanced types, such as `ref`, `reactive`, `shallowRef`, `shallowReactive` and `NuxtError`.
138
138
 
139
+ #### Custom Reducer/Reviver
140
+
139
141
  Since [Nuxt v3.4](https://nuxt.com/blog/v3-4#payload-enhancements), it is possible to define your own reducer/reviver for types that are not supported by Nuxt.
140
142
 
141
143
  :video-accordion{title="Watch a video from Alexander Lichter about serializing payloads, especially with regards to classes" videoId="8w6ffRBs8a4"}
@@ -268,7 +270,7 @@ Using a new experimental feature, it is possible to enable native async context
268
270
  Native async context support works currently in Bun and Node.
269
271
  ::
270
272
 
271
- :read-more{to="/docs/guide/going-further/experimental-features#asynccontext"}
273
+ :read-more{to="/docs/3.x/guide/going-further/experimental-features#asynccontext"}
272
274
 
273
275
  ## tryUseNuxtApp
274
276
 
@@ -1,8 +1,6 @@
1
1
  ---
2
2
  title: 'useRouteAnnouncer'
3
3
  description: This composable observes the page title changes and updates the announcer message accordingly.
4
- navigation:
5
- badge: New
6
4
  links:
7
5
  - label: Source
8
6
  icon: i-simple-icons-github
@@ -76,7 +76,7 @@ The `useRoute()` composable should only be used in the setup function of a Vue c
76
76
  This applies to any composable that uses `useRoute()` internally too.
77
77
  ::
78
78
 
79
- ::read-more{to="/docs/3.x/directory-structure/app/middleware"}
79
+ ::read-more{to="/docs/3.x/directory-structure/middleware"}
80
80
  Read more about accessing the route in the middleware section.
81
81
  ::
82
82
 
@@ -84,4 +84,4 @@ Read more about accessing the route in the middleware section.
84
84
 
85
85
  Browsers don't send [URL fragments](https://url.spec.whatwg.org/#concept-url-fragment) (for example `#foo`) when making requests. So using `route.fullPath` to affect the template can trigger hydration issues because this will include the fragment on client but not the server.
86
86
 
87
- :read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/type-aliases/RouteLocationNormalizedLoaded.html"}
87
+ :read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/type-aliases/routelocationnormalizedloaded"}
@@ -26,17 +26,17 @@ If you only need the router instance within your template, use `$router`:
26
26
 
27
27
  If you have a `pages/` directory, `useRouter` is identical in behavior to the one provided by `vue-router`.
28
28
 
29
- ::read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/interfaces/Router.html#Properties-currentRoute" target="_blank"}
29
+ ::read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/interfaces/router#Properties-currentRoute-" target="_blank"}
30
30
  Read `vue-router` documentation about the `Router` interface.
31
31
  ::
32
32
 
33
33
  ## Basic Manipulation
34
34
 
35
- - [`addRoute()`](https://router.vuejs.org/api/interfaces/Router.html#addRoute): Add a new route to the router instance. `parentName` can be provided to add new route as the child of an existing route.
36
- - [`removeRoute()`](https://router.vuejs.org/api/interfaces/Router.html#removeRoute): Remove an existing route by its name.
37
- - [`getRoutes()`](https://router.vuejs.org/api/interfaces/Router.html#getRoutes): Get a full list of all the route records.
38
- - [`hasRoute()`](https://router.vuejs.org/api/interfaces/Router.html#hasRoute): Checks if a route with a given name exists.
39
- - [`resolve()`](https://router.vuejs.org/api/interfaces/Router.html#resolve): Returns the normalized version of a route location. Also includes an `href` property that includes any existing base.
35
+ - [`addRoute()`](https://router.vuejs.org/api/interfaces/router#addRoute-): Add a new route to the router instance. `parentName` can be provided to add new route as the child of an existing route.
36
+ - [`removeRoute()`](https://router.vuejs.org/api/interfaces/router#removeRoute-): Remove an existing route by its name.
37
+ - [`getRoutes()`](https://router.vuejs.org/api/interfaces/router#getRoutes-): Get a full list of all the route records.
38
+ - [`hasRoute()`](https://router.vuejs.org/api/interfaces/router#hasRoute-): Checks if a route with a given name exists.
39
+ - [`resolve()`](https://router.vuejs.org/api/interfaces/router#resolve-): Returns the normalized version of a route location. Also includes an `href` property that includes any existing base.
40
40
 
41
41
  ```ts [Example]
42
42
  const router = useRouter()
@@ -54,11 +54,11 @@ router.resolve({ name: 'home' })
54
54
 
55
55
  ## Based on History API
56
56
 
57
- - [`back()`](https://router.vuejs.org/api/interfaces/Router.html#back): Go back in history if possible, same as `router.go(-1)`.
58
- - [`forward()`](https://router.vuejs.org/api/interfaces/Router.html#forward): Go forward in history if possible, same as `router.go(1)`.
59
- - [`go()`](https://router.vuejs.org/api/interfaces/Router.html#go): Move forward or backward through the history without the hierarchical restrictions enforced in `router.back()` and `router.forward()`.
60
- - [`push()`](https://router.vuejs.org/api/interfaces/Router.html#push): Programmatically navigate to a new URL by pushing an entry in the history stack. **It is recommended to use [`navigateTo`](/docs/3.x/api/utils/navigate-to) instead.**
61
- - [`replace()`](https://router.vuejs.org/api/interfaces/Router.html#replace): Programmatically navigate to a new URL by replacing the current entry in the routes history stack. **It is recommended to use [`navigateTo`](/docs/3.x/api/utils/navigate-to) instead.**
57
+ - [`back()`](https://router.vuejs.org/api/interfaces/router#back-): Go back in history if possible, same as `router.go(-1)`.
58
+ - [`forward()`](https://router.vuejs.org/api/interfaces/router#forward-): Go forward in history if possible, same as `router.go(1)`.
59
+ - [`go()`](https://router.vuejs.org/api/interfaces/router#go-): Move forward or backward through the history without the hierarchical restrictions enforced in `router.back()` and `router.forward()`.
60
+ - [`push()`](https://router.vuejs.org/api/interfaces/router#push-): Programmatically navigate to a new URL by pushing an entry in the history stack. **It is recommended to use [`navigateTo`](/docs/3.x/api/utils/navigate-to) instead.**
61
+ - [`replace()`](https://router.vuejs.org/api/interfaces/router#replace-): Programmatically navigate to a new URL by replacing the current entry in the routes history stack. **It is recommended to use [`navigateTo`](/docs/3.x/api/utils/navigate-to) instead.**
62
62
 
63
63
  ```ts [Example]
64
64
  const router = useRouter()
@@ -80,14 +80,14 @@ Read more about the browser's History API.
80
80
 
81
81
  However, Nuxt has a concept of **route middleware** that simplifies the implementation of navigation guards and provides a better developer experience.
82
82
 
83
- :read-more{to="/docs/guide/directory-structure/middleware"}
83
+ :read-more{to="/docs/3.x/directory-structure/middleware"}
84
84
 
85
85
  ## Promise and Error Handling
86
86
 
87
- - [`isReady()`](https://router.vuejs.org/api/interfaces/Router.html#isReady): Returns a Promise that resolves when the router has completed the initial navigation.
88
- - [`onError`](https://router.vuejs.org/api/interfaces/Router.html#onError): Adds an error handler that is called every time a non caught error happens during navigation.
87
+ - [`isReady()`](https://router.vuejs.org/api/interfaces/router#isReady-): Returns a Promise that resolves when the router has completed the initial navigation.
88
+ - [`onError`](https://router.vuejs.org/api/interfaces/router#onError-): Adds an error handler that is called every time a non caught error happens during navigation.
89
89
 
90
- :read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/interfaces/Router.html#Methods" title="Vue Router Docs" target="_blank"}
90
+ :read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/interfaces/router#Methods-" title="Vue Router Docs" target="_blank"}
91
91
 
92
92
  ## Universal Router Instance
93
93
 
@@ -22,7 +22,7 @@ export default defineEventHandler((event) => {
22
22
  })
23
23
  ```
24
24
 
25
- :read-more{to="/docs/guide/going-further/runtime-config"}
25
+ :read-more{to="/docs/3.x/guide/going-further/runtime-config"}
26
26
 
27
27
  ## Define Runtime Config
28
28
 
@@ -48,7 +48,7 @@ export default defineNuxtConfig({
48
48
  Variables that need to be accessible on the server are added directly inside `runtimeConfig`. Variables that need to be accessible on both the client and the server are defined in `runtimeConfig.public`.
49
49
  ::
50
50
 
51
- :read-more{to="/docs/guide/going-further/runtime-config"}
51
+ :read-more{to="/docs/3.x/guide/going-further/runtime-config"}
52
52
 
53
53
  ## Access Runtime Config
54
54
 
@@ -76,7 +76,7 @@ In this example, since `apiBase` is defined within the `public` namespace, it is
76
76
 
77
77
  It is possible to update runtime config values using a matching environment variable name prefixed with `NUXT_`.
78
78
 
79
- :read-more{to="/docs/guide/going-further/runtime-config"}
79
+ :read-more{to="/docs/3.x/guide/going-further/runtime-config"}
80
80
 
81
81
  ### Using the `.env` File
82
82
 
@@ -95,7 +95,7 @@ Any environment variables set within `.env` file are accessed using `process.env
95
95
  In **production runtime**, you should use platform environment variables and `.env` is not used.
96
96
  ::
97
97
 
98
- :read-more{to="/docs/guide/directory-structure/env"}
98
+ :read-more{to="/docs/3.x/directory-structure/env"}
99
99
 
100
100
  ## `app` namespace
101
101
 
@@ -139,4 +139,4 @@ export default defineEventHandler((event) => {
139
139
  })
140
140
  ```
141
141
 
142
- :read-more{to="/docs/guide/going-further/runtime-config"}
142
+ :read-more{to="/docs/3.x/guide/going-further/runtime-config"}
@@ -14,7 +14,7 @@ This helps you avoid common mistakes, such as using `name` instead of `property`
14
14
  This is the recommended way to add meta tags to your site as it is XSS safe and has full TypeScript support.
15
15
  ::
16
16
 
17
- :read-more{to="/docs/getting-started/seo-meta"}
17
+ :read-more{to="/docs/3.x/getting-started/seo-meta"}
18
18
 
19
19
  ## Usage
20
20
 
@@ -48,7 +48,7 @@ useSeoMeta({
48
48
 
49
49
  There are over 100 parameters. See the [full list of parameters in the source code](https://github.com/harlan-zw/zhead/blob/main/packages/zhead/src/metaFlat.ts#L1035).
50
50
 
51
- :read-more{to="/docs/getting-started/seo-meta"}
51
+ :read-more{to="/docs/3.x/getting-started/seo-meta"}
52
52
 
53
53
  ## Performance
54
54
 
@@ -10,7 +10,7 @@ links:
10
10
 
11
11
  Just like [`useSeoMeta`](/docs/3.x/api/composables/use-seo-meta), `useServerSeoMeta` composable lets you define your site's SEO meta tags as a flat object with full TypeScript support.
12
12
 
13
- :read-more{to="/docs/api/composables/use-seo-meta"}
13
+ :read-more{to="/docs/3.x/api/composables/use-seo-meta"}
14
14
 
15
15
  In most instances, the meta doesn't need to be reactive as robots will only scan the initial load. So we recommend using [`useServerSeoMeta`](/docs/3.x/api/composables/use-server-seo-meta) as a performance-focused utility that will not do anything (or return a `head` object) on the client.
16
16
 
@@ -24,4 +24,4 @@ useServerSeoMeta({
24
24
 
25
25
  Parameters are exactly the same as with [`useSeoMeta`](/docs/3.x/api/composables/use-seo-meta)
26
26
 
27
- :read-more{to="/docs/getting-started/seo-meta"}
27
+ :read-more{to="/docs/3.x/getting-started/seo-meta"}
@@ -15,7 +15,7 @@ links:
15
15
  const count = useState('counter', () => Math.round(Math.random() * 100))
16
16
  ```
17
17
 
18
- :read-more{to="/docs/getting-started/state-management"}
18
+ :read-more{to="/docs/3.x/getting-started/state-management"}
19
19
 
20
20
  ::important
21
21
  Because the data inside `useState` will be serialized to JSON, it is important that it does not contain anything that cannot be serialized, such as classes, functions or symbols.
@@ -29,7 +29,7 @@ Because the data inside `useState` will be serialized to JSON, it is important t
29
29
 
30
30
  ## Using `shallowRef`
31
31
 
32
- If you don't need your state to be deeply reactive, you can combine `useState` with [`shallowRef`](https://vuejs.org/api/reactivity-advanced.html#shallowref). This can improve performance when your state contains large objects and arrays.
32
+ If you don't need your state to be deeply reactive, you can combine `useState` with [`shallowRef`](https://vuejs.org/api/reactivity-advanced#shallowref). This can improve performance when your state contains large objects and arrays.
33
33
 
34
34
  ```ts
35
35
  const state = useState('my-shallow-state', () => shallowRef({ deep: 'not reactive' }))
@@ -46,3 +46,13 @@ export function useState<T> (key: string, init?: () => T | Ref<T>): Ref<T>
46
46
  - `key`: A unique key ensuring that data fetching is properly de-duplicated across requests. If you do not provide a key, then a key that is unique to the file and line number of the instance of [`useState`](/docs/3.x/api/composables/use-state) will be generated for you.
47
47
  - `init`: A function that provides initial value for the state when not initiated. This function can also return a `Ref`.
48
48
  - `T`: (typescript only) Specify the type of state
49
+
50
+ ## Troubleshooting
51
+
52
+ ### `Cannot stringify arbitrary non-POJOs`
53
+
54
+ This error occurs when you try to store a non-serializable payload with `useState`, such as class instances.
55
+
56
+ If you want to store class instances with `useState` that are not supported by Nuxt, you can use [`definePayloadPlugin`](/docs/3.x/api/composables/use-nuxt-app#custom-reducerreviver) to add a custom serializer and deserializer for your classes.
57
+
58
+ :read-more{to="/docs/3.x/api/composables/use-nuxt-app#payload"}
@@ -35,7 +35,7 @@ const { data } = await useFetch('/api/item')
35
35
  </script>
36
36
  ```
37
37
 
38
- :read-more{to="/docs/getting-started/data-fetching"}
38
+ :read-more{to="/docs/3.x/getting-started/data-fetching"}
39
39
 
40
40
  You can use `$fetch` in any methods that are executed only on client-side.
41
41
 
@@ -22,7 +22,7 @@ export function abortNavigation (err?: Error | string): false
22
22
 
23
23
  ### `err`
24
24
 
25
- - **Type**: [`Error`](https://developer.mozilla.org/pl/docs/Web/JavaScript/Reference/Global_Objects/Error) | `string`
25
+ - **Type**: [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) | `string`
26
26
 
27
27
  Optional error to be thrown by `abortNavigation`.
28
28
 
@@ -60,7 +60,7 @@ export default defineNuxtRouteMiddleware((to, from) => {
60
60
 
61
61
  ### `err` as an Error Object
62
62
 
63
- You can pass the error as an [`Error`](https://developer.mozilla.org/pl/docs/Web/JavaScript/Reference/Global_Objects/Error) object, e.g. caught by the `catch`-block:
63
+ You can pass the error as an [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object, e.g. caught by the `catch`-block:
64
64
 
65
65
  ```ts [middleware/auth.ts]
66
66
  export default defineNuxtRouteMiddleware((to, from) => {
@@ -1,8 +1,6 @@
1
1
  ---
2
2
  title: "callOnce"
3
3
  description: "Run a given function or block of code once during SSR or CSR."
4
- navigation:
5
- badge: New
6
4
  links:
7
5
  - label: Source
8
6
  icon: i-simple-icons-github
@@ -54,11 +52,11 @@ await callOnce(async () => {
54
52
  `navigation` mode is available since [Nuxt v3.15](/blog/v3-15).
55
53
  ::
56
54
 
57
- ::tip{to="/docs/getting-started/state-management#usage-with-pinia"}
55
+ ::tip{to="/docs/3.x/getting-started/state-management#usage-with-pinia"}
58
56
  `callOnce` is useful in combination with the [Pinia module](/modules/pinia) to call store actions.
59
57
  ::
60
58
 
61
- :read-more{to="/docs/getting-started/state-management"}
59
+ :read-more{to="/docs/3.x/getting-started/state-management"}
62
60
 
63
61
  ::warning
64
62
  Note that `callOnce` doesn't return anything. You should use [`useAsyncData`](/docs/3.x/api/composables/use-async-data) or [`useFetch`](/docs/3.x/api/composables/use-fetch) if you want to do data fetching during SSR.
@@ -26,4 +26,4 @@ clearError({ redirect: '/homepage' })
26
26
 
27
27
  Errors are set in state using [`useError()`](/docs/3.x/api/composables/use-error). The `clearError` composable will reset this state and calls the `app:error:cleared` hook with the provided options.
28
28
 
29
- :read-more{to="/docs/getting-started/error-handling"}
29
+ :read-more{to="/docs/3.x/getting-started/error-handling"}
@@ -12,9 +12,9 @@ You can use this function to create an error object with additional metadata. It
12
12
 
13
13
  ## Parameters
14
14
 
15
- - `err`: `string | { cause, data, message, name, stack, statusCode, statusMessage, fatal }`
15
+ - `err`: `string | { cause, data, message, name, stack, status, statusText, fatal }`
16
16
 
17
- You can pass either a string or an object to the `createError` function. If you pass a string, it will be used as the error `message`, and the `statusCode` will default to `500`. If you pass an object, you can set multiple properties of the error, such as `statusCode`, `message`, and other error properties.
17
+ You can pass either a string or an object to the `createError` function. If you pass a string, it will be used as the error `message`, and the `status` will default to `500`. If you pass an object, you can set multiple properties of the error, such as `status`, `message`, and other error properties.
18
18
 
19
19
  ## In Vue App
20
20
 
@@ -30,7 +30,7 @@ If you throw an error created with `createError`:
30
30
  const route = useRoute()
31
31
  const { data } = await useFetch(`/api/movies/${route.params.slug}`)
32
32
  if (!data.value) {
33
- throw createError({ statusCode: 404, statusMessage: 'Page Not Found' })
33
+ throw createError({ status: 404, statusText: 'Page Not Found' })
34
34
  }
35
35
  </script>
36
36
  ```
@@ -44,12 +44,12 @@ Use `createError` to trigger error handling in server API routes.
44
44
  ```ts [server/api/error.ts]
45
45
  export default eventHandler(() => {
46
46
  throw createError({
47
- statusCode: 404,
48
- statusMessage: 'Page Not Found',
47
+ status: 404,
48
+ statusText: 'Page Not Found',
49
49
  })
50
50
  })
51
51
  ```
52
52
 
53
- In API routes, using `createError` by passing an object with a short `statusMessage` is recommended because it can be accessed on the client side. Otherwise, a `message` passed to `createError` on an API route will not propagate to the client. Alternatively, you can use the `data` property to pass data back to the client. In any case, always consider avoiding to put dynamic user input to the message to avoid potential security issues.
53
+ In API routes, using `createError` by passing an object with a short `statusText` is recommended because it can be accessed on the client side. Otherwise, a `message` passed to `createError` on an API route will not propagate to the client. Alternatively, you can use the `data` property to pass data back to the client. In any case, always consider avoiding to put dynamic user input to the message to avoid potential security issues.
54
54
 
55
- :read-more{to="/docs/getting-started/error-handling"}
55
+ :read-more{to="/docs/3.x/getting-started/error-handling"}