@nuxt/docs 4.2.1 → 4.3.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 (246) hide show
  1. package/1.getting-started/01.introduction.md +1 -1
  2. package/1.getting-started/02.installation.md +2 -5
  3. package/1.getting-started/03.configuration.md +27 -27
  4. package/1.getting-started/04.views.md +5 -5
  5. package/1.getting-started/05.assets.md +7 -7
  6. package/1.getting-started/06.styling.md +9 -5
  7. package/1.getting-started/07.routing.md +8 -8
  8. package/1.getting-started/08.seo-meta.md +7 -3
  9. package/1.getting-started/09.transitions.md +6 -6
  10. package/1.getting-started/10.data-fetching.md +2 -2
  11. package/1.getting-started/11.state-management.md +2 -2
  12. package/1.getting-started/12.error-handling.md +15 -9
  13. package/1.getting-started/13.server.md +2 -2
  14. package/1.getting-started/14.layers.md +50 -16
  15. package/1.getting-started/15.prerendering.md +6 -0
  16. package/1.getting-started/16.deployment.md +2 -1
  17. package/1.getting-started/17.testing.md +44 -3
  18. package/1.getting-started/18.upgrade.md +37 -24
  19. package/{2.guide/1.directory-structure → 2.directory-structure}/0.nuxt.md +1 -1
  20. package/{2.guide/1.directory-structure → 2.directory-structure}/0.output.md +1 -1
  21. package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.assets.md +2 -2
  22. package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.components.md +6 -2
  23. package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.composables.md +2 -2
  24. package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.layouts.md +35 -3
  25. package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.middleware.md +1 -1
  26. package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.pages.md +28 -7
  27. package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.plugins.md +5 -2
  28. package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.utils.md +3 -3
  29. package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/3.app.md +4 -4
  30. package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/3.error.md +10 -8
  31. package/{2.guide/1.directory-structure → 2.directory-structure}/1.content.md +2 -2
  32. package/2.directory-structure/1.layers.md +87 -0
  33. package/{2.guide/1.directory-structure → 2.directory-structure}/1.modules.md +13 -3
  34. package/{2.guide/1.directory-structure → 2.directory-structure}/1.node_modules.md +2 -2
  35. package/{2.guide/1.directory-structure → 2.directory-structure}/1.server.md +27 -7
  36. package/{2.guide/1.directory-structure → 2.directory-structure}/1.shared.md +3 -3
  37. package/{2.guide/1.directory-structure → 2.directory-structure}/2.env.md +2 -2
  38. package/{2.guide/1.directory-structure → 2.directory-structure}/2.nuxtignore.md +1 -1
  39. package/{2.guide/1.directory-structure → 2.directory-structure}/2.nuxtrc.md +4 -1
  40. package/{2.guide/1.directory-structure → 2.directory-structure}/3.nuxt-config.md +1 -1
  41. package/{2.guide/1.directory-structure → 2.directory-structure}/3.package.md +1 -1
  42. package/{2.guide/1.directory-structure → 2.directory-structure}/3.tsconfig.md +1 -0
  43. package/2.directory-structure/index.md +65 -0
  44. package/{2.guide → 3.guide}/0.index.md +10 -7
  45. package/{2.guide/2.concepts/3.rendering.md → 3.guide/1.concepts/1.rendering.md} +2 -27
  46. package/{2.guide/2.concepts/2.vuejs-development.md → 3.guide/1.concepts/10.vuejs-development.md} +4 -3
  47. package/{2.guide/2.concepts/10.nuxt-lifecycle.md → 3.guide/1.concepts/2.nuxt-lifecycle.md} +33 -26
  48. package/{2.guide/2.concepts/1.auto-imports.md → 3.guide/1.concepts/3.auto-imports.md} +5 -5
  49. package/{2.guide/2.concepts → 3.guide/1.concepts}/4.server-engine.md +3 -3
  50. package/{2.guide/2.concepts → 3.guide/1.concepts}/5.modules.md +15 -2
  51. package/{2.guide/2.concepts → 3.guide/1.concepts}/7.esm.md +1 -0
  52. package/{2.guide/2.concepts → 3.guide/1.concepts}/8.typescript.md +9 -5
  53. package/{2.guide/5.best-practices → 3.guide/2.best-practices}/performance.md +2 -2
  54. package/3.guide/3.ai/.navigation.yml +3 -0
  55. package/3.guide/3.ai/1.mcp.md +277 -0
  56. package/3.guide/3.ai/2.llms-txt.md +65 -0
  57. package/3.guide/4.modules/.navigation.yml +3 -0
  58. package/3.guide/4.modules/1.getting-started.md +103 -0
  59. package/3.guide/4.modules/2.module-anatomy.md +138 -0
  60. package/3.guide/4.modules/3.recipes-basics.md +330 -0
  61. package/3.guide/4.modules/4.recipes-advanced.md +243 -0
  62. package/3.guide/4.modules/5.testing.md +76 -0
  63. package/3.guide/4.modules/6.best-practices.md +104 -0
  64. package/3.guide/4.modules/7.ecosystem.md +32 -0
  65. package/3.guide/4.modules/index.md +36 -0
  66. package/{2.guide/4.recipes → 3.guide/5.recipes}/1.custom-routing.md +1 -1
  67. package/{2.guide/4.recipes → 3.guide/5.recipes}/2.vite-plugin.md +5 -1
  68. package/{2.guide/4.recipes → 3.guide/5.recipes}/3.custom-usefetch.md +2 -2
  69. package/{2.guide/4.recipes → 3.guide/5.recipes}/4.sessions-and-authentication.md +2 -2
  70. package/{2.guide/3.going-further → 3.guide/6.going-further}/1.events.md +2 -3
  71. package/{2.guide/3.going-further → 3.guide/6.going-further}/1.experimental-features.md +19 -4
  72. package/{2.guide/3.going-further → 3.guide/6.going-further}/1.internals.md +5 -4
  73. package/{2.guide/3.going-further → 3.guide/6.going-further}/10.runtime-config.md +3 -3
  74. package/{2.guide/3.going-further → 3.guide/6.going-further}/2.hooks.md +3 -3
  75. package/{2.guide/3.going-further → 3.guide/6.going-further}/4.kit.md +1 -1
  76. package/{2.guide/3.going-further → 3.guide/6.going-further}/6.nuxt-app.md +3 -3
  77. package/{2.guide/3.going-further → 3.guide/6.going-further}/7.layers.md +38 -12
  78. package/{3.api → 4.api}/1.components/1.nuxt-client-fallback.md +4 -0
  79. package/{3.api → 4.api}/1.components/12.nuxt-route-announcer.md +1 -3
  80. package/{3.api → 4.api}/1.components/13.nuxt-time.md +0 -2
  81. package/{3.api → 4.api}/1.components/2.nuxt-page.md +2 -2
  82. package/{3.api → 4.api}/1.components/3.nuxt-layout.md +6 -6
  83. package/{3.api → 4.api}/1.components/5.nuxt-loading-indicator.md +1 -1
  84. package/{3.api → 4.api}/1.components/7.nuxt-welcome.md +2 -2
  85. package/{3.api → 4.api}/1.components/8.nuxt-island.md +9 -2
  86. package/{3.api → 4.api}/2.composables/use-app-config.md +1 -1
  87. package/{3.api → 4.api}/2.composables/use-async-data.md +3 -3
  88. package/4.api/2.composables/use-cookie.md +183 -0
  89. package/{3.api → 4.api}/2.composables/use-error.md +2 -2
  90. package/{3.api → 4.api}/2.composables/use-fetch.md +33 -33
  91. package/{3.api → 4.api}/2.composables/use-head.md +16 -1
  92. package/{3.api → 4.api}/2.composables/use-lazy-fetch.md +8 -8
  93. package/{3.api → 4.api}/2.composables/use-nuxt-app.md +6 -4
  94. package/{3.api → 4.api}/2.composables/use-response-header.md +1 -1
  95. package/{3.api → 4.api}/2.composables/use-route-announcer.md +0 -2
  96. package/{3.api → 4.api}/2.composables/use-route.md +1 -1
  97. package/{3.api → 4.api}/2.composables/use-router.md +2 -2
  98. package/{3.api → 4.api}/2.composables/use-runtime-config.md +1 -1
  99. package/{3.api → 4.api}/2.composables/use-state.md +10 -0
  100. package/{3.api → 4.api}/3.utils/$fetch.md +1 -1
  101. package/{3.api → 4.api}/3.utils/abort-navigation.md +1 -1
  102. package/{3.api → 4.api}/3.utils/add-route-middleware.md +1 -1
  103. package/{3.api → 4.api}/3.utils/call-once.md +0 -2
  104. package/{3.api → 4.api}/3.utils/create-error.md +6 -6
  105. package/{3.api → 4.api}/3.utils/define-nuxt-plugin.md +12 -12
  106. package/{3.api → 4.api}/3.utils/define-nuxt-route-middleware.md +2 -2
  107. package/{3.api → 4.api}/3.utils/define-page-meta.md +14 -7
  108. package/{3.api → 4.api}/3.utils/navigate-to.md +10 -10
  109. package/{3.api → 4.api}/3.utils/refresh-cookie.md +0 -2
  110. package/{3.api → 4.api}/3.utils/set-page-layout.md +36 -0
  111. package/{3.api → 4.api}/3.utils/set-response-status.md +2 -2
  112. package/{3.api → 4.api}/3.utils/show-error.md +3 -3
  113. package/{3.api → 4.api}/3.utils/update-app-config.md +2 -2
  114. package/{3.api → 4.api}/4.commands/add.md +11 -11
  115. package/4.api/4.commands/analyze.md +42 -0
  116. package/4.api/4.commands/build-module.md +42 -0
  117. package/4.api/4.commands/build.md +47 -0
  118. package/{3.api → 4.api}/4.commands/cleanup.md +6 -6
  119. package/4.api/4.commands/dev.md +60 -0
  120. package/{3.api → 4.api}/4.commands/devtools.md +7 -7
  121. package/4.api/4.commands/generate.md +42 -0
  122. package/4.api/4.commands/info.md +33 -0
  123. package/4.api/4.commands/init.md +50 -0
  124. package/4.api/4.commands/module.md +84 -0
  125. package/4.api/4.commands/prepare.md +41 -0
  126. package/4.api/4.commands/preview.md +44 -0
  127. package/4.api/4.commands/test.md +40 -0
  128. package/4.api/4.commands/typecheck.md +44 -0
  129. package/4.api/4.commands/upgrade.md +37 -0
  130. package/{3.api → 4.api}/5.kit/1.modules.md +30 -17
  131. package/{3.api → 4.api}/5.kit/10.templates.md +23 -23
  132. package/{3.api → 4.api}/5.kit/11.nitro.md +35 -35
  133. package/{3.api → 4.api}/5.kit/14.builder.md +29 -17
  134. package/{3.api → 4.api}/5.kit/16.layers.md +12 -12
  135. package/{3.api → 4.api}/5.kit/2.programmatic.md +2 -2
  136. package/{3.api → 4.api}/5.kit/4.autoimports.md +18 -18
  137. package/4.api/5.kit/5.components.md +146 -0
  138. package/4.api/6.advanced/1.hooks.md +105 -0
  139. package/{3.api → 4.api}/6.nuxt-config.md +7 -6
  140. package/5.community/4.contribution.md +5 -5
  141. package/5.community/5.framework-contribution.md +1 -1
  142. package/5.community/6.roadmap.md +25 -25
  143. package/5.community/7.changelog.md +20 -0
  144. package/6.bridge/1.overview.md +9 -1
  145. package/6.bridge/2.typescript.md +1 -1
  146. package/6.bridge/3.bridge-composition-api.md +1 -1
  147. package/6.bridge/4.plugins-and-middleware.md +3 -3
  148. package/6.bridge/8.nitro.md +4 -0
  149. package/7.migration/11.server.md +1 -1
  150. package/7.migration/2.configuration.md +4 -4
  151. package/7.migration/20.module-authors.md +3 -3
  152. package/7.migration/3.auto-imports.md +1 -1
  153. package/7.migration/5.plugins-and-middleware.md +2 -2
  154. package/7.migration/6.pages-and-layouts.md +6 -6
  155. package/7.migration/7.component-options.md +1 -1
  156. package/package.json +1 -1
  157. package/2.guide/3.going-further/3.modules.md +0 -968
  158. package/3.api/2.composables/use-cookie.md +0 -183
  159. package/3.api/4.commands/analyze.md +0 -42
  160. package/3.api/4.commands/build-module.md +0 -42
  161. package/3.api/4.commands/build.md +0 -47
  162. package/3.api/4.commands/dev.md +0 -60
  163. package/3.api/4.commands/generate.md +0 -42
  164. package/3.api/4.commands/info.md +0 -33
  165. package/3.api/4.commands/init.md +0 -50
  166. package/3.api/4.commands/module.md +0 -84
  167. package/3.api/4.commands/prepare.md +0 -41
  168. package/3.api/4.commands/preview.md +0 -44
  169. package/3.api/4.commands/test.md +0 -40
  170. package/3.api/4.commands/typecheck.md +0 -44
  171. package/3.api/4.commands/upgrade.md +0 -37
  172. package/3.api/5.kit/5.components.md +0 -146
  173. package/3.api/6.advanced/1.hooks.md +0 -105
  174. /package/{2.guide/1.directory-structure → 2.directory-structure}/.navigation.yml +0 -0
  175. /package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/.navigation.yml +0 -0
  176. /package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/3.app-config.md +0 -0
  177. /package/{2.guide/1.directory-structure → 2.directory-structure}/1.public.md +0 -0
  178. /package/{2.guide/1.directory-structure → 2.directory-structure}/2.gitignore.md +0 -0
  179. /package/{2.guide → 3.guide}/.navigation.yml +0 -0
  180. /package/{2.guide/2.concepts → 3.guide/1.concepts}/.navigation.yml +0 -0
  181. /package/{2.guide/2.concepts → 3.guide/1.concepts}/9.code-style.md +0 -0
  182. /package/{2.guide/5.best-practices → 3.guide/2.best-practices}/.navigation.yml +0 -0
  183. /package/{2.guide/5.best-practices → 3.guide/2.best-practices}/hydration.md +0 -0
  184. /package/{2.guide/5.best-practices → 3.guide/2.best-practices}/plugins.md +0 -0
  185. /package/{2.guide/4.recipes → 3.guide/5.recipes}/.navigation.yml +0 -0
  186. /package/{2.guide/3.going-further → 3.guide/6.going-further}/.navigation.yml +0 -0
  187. /package/{2.guide/3.going-further → 3.guide/6.going-further}/1.features.md +0 -0
  188. /package/{2.guide/3.going-further → 3.guide/6.going-further}/11.nightly-release-channel.md +0 -0
  189. /package/{2.guide/3.going-further → 3.guide/6.going-further}/9.debugging.md +0 -0
  190. /package/{2.guide/3.going-further → 3.guide/6.going-further}/index.md +0 -0
  191. /package/{3.api → 4.api}/.navigation.yml +0 -0
  192. /package/{3.api → 4.api}/1.components/.navigation.yml +0 -0
  193. /package/{3.api → 4.api}/1.components/1.client-only.md +0 -0
  194. /package/{3.api → 4.api}/1.components/1.dev-only.md +0 -0
  195. /package/{3.api → 4.api}/1.components/10.nuxt-picture.md +0 -0
  196. /package/{3.api → 4.api}/1.components/11.teleports.md +0 -0
  197. /package/{3.api → 4.api}/1.components/4.nuxt-link.md +0 -0
  198. /package/{3.api → 4.api}/1.components/6.nuxt-error-boundary.md +0 -0
  199. /package/{3.api → 4.api}/1.components/9.nuxt-img.md +0 -0
  200. /package/{3.api → 4.api}/2.composables/.navigation.yml +0 -0
  201. /package/{3.api → 4.api}/2.composables/on-prehydrate.md +0 -0
  202. /package/{3.api → 4.api}/2.composables/use-head-safe.md +0 -0
  203. /package/{3.api → 4.api}/2.composables/use-hydration.md +0 -0
  204. /package/{3.api → 4.api}/2.composables/use-lazy-async-data.md +0 -0
  205. /package/{3.api → 4.api}/2.composables/use-loading-indicator.md +0 -0
  206. /package/{3.api → 4.api}/2.composables/use-nuxt-data.md +0 -0
  207. /package/{3.api → 4.api}/2.composables/use-preview-mode.md +0 -0
  208. /package/{3.api → 4.api}/2.composables/use-request-event.md +0 -0
  209. /package/{3.api → 4.api}/2.composables/use-request-fetch.md +0 -0
  210. /package/{3.api → 4.api}/2.composables/use-request-header.md +0 -0
  211. /package/{3.api → 4.api}/2.composables/use-request-headers.md +0 -0
  212. /package/{3.api → 4.api}/2.composables/use-request-url.md +0 -0
  213. /package/{3.api → 4.api}/2.composables/use-runtime-hook.md +0 -0
  214. /package/{3.api → 4.api}/2.composables/use-seo-meta.md +0 -0
  215. /package/{3.api → 4.api}/2.composables/use-server-seo-meta.md +0 -0
  216. /package/{3.api → 4.api}/3.utils/.navigation.yml +0 -0
  217. /package/{3.api → 4.api}/3.utils/clear-error.md +0 -0
  218. /package/{3.api → 4.api}/3.utils/clear-nuxt-data.md +0 -0
  219. /package/{3.api → 4.api}/3.utils/clear-nuxt-state.md +0 -0
  220. /package/{3.api → 4.api}/3.utils/define-lazy-hydration-component.md +0 -0
  221. /package/{3.api → 4.api}/3.utils/define-nuxt-component.md +0 -0
  222. /package/{3.api → 4.api}/3.utils/define-route-rules.md +0 -0
  223. /package/{3.api → 4.api}/3.utils/on-before-route-leave.md +0 -0
  224. /package/{3.api → 4.api}/3.utils/on-before-route-update.md +0 -0
  225. /package/{3.api → 4.api}/3.utils/on-nuxt-ready.md +0 -0
  226. /package/{3.api → 4.api}/3.utils/prefetch-components.md +0 -0
  227. /package/{3.api → 4.api}/3.utils/preload-components.md +0 -0
  228. /package/{3.api → 4.api}/3.utils/preload-route-components.md +0 -0
  229. /package/{3.api → 4.api}/3.utils/prerender-routes.md +0 -0
  230. /package/{3.api → 4.api}/3.utils/refresh-nuxt-data.md +0 -0
  231. /package/{3.api → 4.api}/3.utils/reload-nuxt-app.md +0 -0
  232. /package/{3.api → 4.api}/4.commands/.navigation.yml +0 -0
  233. /package/{3.api → 4.api}/5.kit/.navigation.yml +0 -0
  234. /package/{3.api → 4.api}/5.kit/10.runtime-config.md +0 -0
  235. /package/{3.api → 4.api}/5.kit/12.resolving.md +0 -0
  236. /package/{3.api → 4.api}/5.kit/13.logging.md +0 -0
  237. /package/{3.api → 4.api}/5.kit/15.examples.md +0 -0
  238. /package/{3.api → 4.api}/5.kit/3.compatibility.md +0 -0
  239. /package/{3.api → 4.api}/5.kit/6.context.md +0 -0
  240. /package/{3.api → 4.api}/5.kit/7.pages.md +0 -0
  241. /package/{3.api → 4.api}/5.kit/8.layout.md +0 -0
  242. /package/{3.api → 4.api}/5.kit/9.head.md +0 -0
  243. /package/{3.api → 4.api}/5.kit/9.plugins.md +0 -0
  244. /package/{3.api → 4.api}/6.advanced/.navigation.yml +0 -0
  245. /package/{3.api → 4.api}/6.advanced/2.import-meta.md +0 -0
  246. /package/{3.api → 4.api}/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/4.x/guide/recipes/custom-usefetch#custom-usefetchuseasyncdata) for more information on how to make a custom async data fetcher.
28
+ ::warning{to="/docs/4.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
@@ -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/4.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` | `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/4.x/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/4.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 `undefined`, 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
 
@@ -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.
@@ -69,14 +69,14 @@ export function useLazyFetch<DataT, ErrorT> (
69
69
 
70
70
  Returns the same `AsyncData` object as [`useFetch`](/docs/4.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/4.x/api/composables/use-fetch#return-values"}
82
82
 
@@ -30,7 +30,7 @@ By default, the shared runtime context of Nuxt is namespaced under the [`buildId
30
30
 
31
31
  ### `provide (name, value)`
32
32
 
33
- `nuxtApp` is a runtime context that you can extend using [Nuxt plugins](/docs/4.x/guide/directory-structure/app/plugins). Use the `provide` function to create Nuxt plugins to make values and helper methods available in your Nuxt application across all composables and components.
33
+ `nuxtApp` is a runtime context that you can extend using [Nuxt plugins](/docs/4.x/directory-structure/app/plugins). Use the `provide` function to create Nuxt plugins to make values and helper methods available in your Nuxt application across all composables and components.
34
34
 
35
35
  `provide` function accepts `name` and `value` parameters.
36
36
 
@@ -46,7 +46,7 @@ As you can see in the example above, `$hello` has become the new and custom part
46
46
 
47
47
  ### `hook(name, cb)`
48
48
 
49
- Hooks available in `nuxtApp` allows you to customize the runtime aspects of your Nuxt application. You can use runtime hooks in Vue.js composables and [Nuxt plugins](/docs/4.x/guide/directory-structure/app/plugins) to hook into the rendering lifecycle.
49
+ Hooks available in `nuxtApp` allows you to customize the runtime aspects of your Nuxt application. You can use runtime hooks in Vue.js composables and [Nuxt plugins](/docs/4.x/directory-structure/app/plugins) to hook into the rendering lifecycle.
50
50
 
51
51
  `hook` function is useful for adding custom logic by hooking into the rendering lifecycle at a specific point. `hook` function is mostly used when creating Nuxt plugins.
52
52
 
@@ -84,8 +84,8 @@ await nuxtApp.callHook('my-plugin:init')
84
84
 
85
85
  Some useful methods:
86
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/4.x/guide/directory-structure/app/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/4.x/guide/directory-structure/app/plugins#vue-plugins).
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/4.x/directory-structure/app/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/4.x/directory-structure/app/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
 
@@ -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"}
@@ -37,7 +37,7 @@ header.value = 'my-value'
37
37
  </template>
38
38
  ```
39
39
 
40
- We can use `useResponseHeader` for example in Nuxt [middleware](/docs/4.x/guide/directory-structure/app/middleware) to set a response header for all pages.
40
+ We can use `useResponseHeader` for example in Nuxt [middleware](/docs/4.x/directory-structure/app/middleware) to set a response header for all pages.
41
41
 
42
42
  ```ts [app/middleware/my-header-middleware.ts]
43
43
  export default defineNuxtRouteMiddleware((to, from) => {
@@ -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/4.x/guide/directory-structure/app/middleware"}
79
+ ::read-more{to="/docs/4.x/directory-structure/app/middleware"}
80
80
  Read more about accessing the route in the middleware section.
81
81
  ::
82
82
 
@@ -49,7 +49,7 @@ router.resolve({ name: 'home' })
49
49
  ```
50
50
 
51
51
  ::note
52
- `router.addRoute()` adds route details into an array of routes and it is useful while building [Nuxt plugins](/docs/4.x/guide/directory-structure/app/plugins) while `router.push()` on the other hand, triggers a new navigation immediately and it is useful in pages, Vue components and composable.
52
+ `router.addRoute()` adds route details into an array of routes and it is useful while building [Nuxt plugins](/docs/4.x/directory-structure/app/plugins) while `router.push()` on the other hand, triggers a new navigation immediately and it is useful in pages, Vue components and composable.
53
53
  ::
54
54
 
55
55
  ## Based on History API
@@ -80,7 +80,7 @@ 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/4.x/guide/directory-structure/app/middleware"}
83
+ :read-more{to="/docs/4.x/directory-structure/app/middleware"}
84
84
 
85
85
  ## Promise and Error Handling
86
86
 
@@ -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/4.x/guide/directory-structure/env"}
98
+ :read-more{to="/docs/4.x/directory-structure/env"}
99
99
 
100
100
  ## `app` namespace
101
101
 
@@ -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/4.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/4.x/api/composables/use-nuxt-app#custom-reducerreviver) to add a custom serializer and deserializer for your classes.
57
+
58
+ :read-more{to="/docs/4.x/api/composables/use-nuxt-app#payload"}
@@ -11,7 +11,7 @@ links:
11
11
  Nuxt uses [ofetch](https://github.com/unjs/ofetch) to expose globally the `$fetch` helper for making HTTP requests within your Vue app or API routes.
12
12
 
13
13
  ::tip{icon="i-lucide-rocket"}
14
- During server-side rendering, calling `$fetch` to fetch your internal [API routes](/docs/4.x/guide/directory-structure/server) will directly call the relevant function (emulating the request), **saving an additional API call**.
14
+ During server-side rendering, calling `$fetch` to fetch your internal [API routes](/docs/4.x/directory-structure/server) will directly call the relevant function (emulating the request), **saving an additional API call**.
15
15
  ::
16
16
 
17
17
  ::note{color="blue" icon="i-lucide-info"}
@@ -9,7 +9,7 @@ links:
9
9
  ---
10
10
 
11
11
  ::warning
12
- `abortNavigation` is only usable inside a [route middleware handler](/docs/4.x/guide/directory-structure/app/middleware).
12
+ `abortNavigation` is only usable inside a [route middleware handler](/docs/4.x/directory-structure/app/middleware).
13
13
  ::
14
14
 
15
15
  ## Type
@@ -9,7 +9,7 @@ links:
9
9
  ---
10
10
 
11
11
  ::note
12
- Route middleware are navigation guards stored in the [`app/middleware/`](/docs/4.x/guide/directory-structure/app/middleware) directory of your Nuxt application (unless [set otherwise](/docs/4.x/api/nuxt-config#middleware)).
12
+ Route middleware are navigation guards stored in the [`app/middleware/`](/docs/4.x/directory-structure/app/middleware) directory of your Nuxt application (unless [set otherwise](/docs/4.x/api/nuxt-config#middleware)).
13
13
  ::
14
14
 
15
15
  ## Type
@@ -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
@@ -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
55
  :read-more{to="/docs/4.x/getting-started/error-handling"}
@@ -16,7 +16,7 @@ export default defineNuxtPlugin((nuxtApp) => {
16
16
  })
17
17
  ```
18
18
 
19
- :read-more{to="/docs/4.x/guide/directory-structure/app/plugins#creating-plugins"}
19
+ :read-more{to="/docs/4.x/directory-structure/app/plugins#creating-plugins"}
20
20
 
21
21
  ## Type
22
22
 
@@ -42,19 +42,19 @@ interface ObjectPlugin<T> {
42
42
  ## Parameters
43
43
 
44
44
  **plugin**: A plugin can be defined in two ways:
45
- 1. **Function Plugin**: A function that receives the [`NuxtApp`](/docs/4.x/guide/going-further/internals#the-nuxtapp-interface) instance and can return a promise with a potential object with a [`provide`](/docs/4.x/guide/directory-structure/app/plugins#providing-helpers) property if you want to provide a helper on [`NuxtApp`](/docs/4.x/guide/going-further/internals#the-nuxtapp-interface) instance.
45
+ 1. **Function Plugin**: A function that receives the [`NuxtApp`](/docs/4.x/guide/going-further/internals#the-nuxtapp-interface) instance and can return a promise with a potential object with a [`provide`](/docs/4.x/directory-structure/app/plugins#providing-helpers) property if you want to provide a helper on [`NuxtApp`](/docs/4.x/guide/going-further/internals#the-nuxtapp-interface) instance.
46
46
  2. **Object Plugin**: An object that can include various properties to configure the plugin's behavior, such as `name`, `enforce`, `dependsOn`, `order`, `parallel`, `setup`, `hooks`, and `env`.
47
47
 
48
- | Property | Type | Required | Description |
49
- | ------------------ | -------------------------------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
50
- | `name` | `string` | `false` | Optional name for the plugin, useful for debugging and dependency management. |
51
- | `enforce` | `'pre'` \| `'default'` \| `'post'` | `false` | Controls when the plugin runs relative to other plugins. |
52
- | `dependsOn` | `string[]` | `false` | Array of plugin names this plugin depends on. Ensures proper execution order. |
53
- | `order` | `number` | `false` | This allows more granular control over plugin order and should only be used by advanced users. **It overrides the value of `enforce` and is used to sort plugins.** |
54
- | `parallel` | `boolean` | `false` | Whether to execute the plugin in parallel with other parallel plugins. |
55
- | `setup` | `Plugin<T>`{lang="ts"} | `false` | The main plugin function, equivalent to a function plugin. |
56
- | `hooks` | `Partial<RuntimeNuxtHooks>`{lang="ts"} | `false` | Nuxt app runtime hooks to register directly. |
57
- | `env` | `{ islands?: boolean }`{lang="ts"} | `false` | Set this value to `false` if you don't want the plugin to run when rendering server-only or island components. |
48
+ | Property | Type | Required | Description |
49
+ |-------------|----------------------------------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
50
+ | `name` | `string` | `false` | Optional name for the plugin, useful for debugging and dependency management. |
51
+ | `enforce` | `'pre'` \| `'default'` \| `'post'` | `false` | Controls when the plugin runs relative to other plugins. |
52
+ | `dependsOn` | `string[]` | `false` | Array of plugin names this plugin depends on. Ensures proper execution order. |
53
+ | `order` | `number` | `false` | This allows more granular control over plugin order and should only be used by advanced users. **It overrides the value of `enforce` and is used to sort plugins.** |
54
+ | `parallel` | `boolean` | `false` | Whether to execute the plugin in parallel with other parallel plugins. |
55
+ | `setup` | `Plugin<T>`{lang="ts"} | `false` | The main plugin function, equivalent to a function plugin. |
56
+ | `hooks` | `Partial<RuntimeNuxtHooks>`{lang="ts"} | `false` | Nuxt app runtime hooks to register directly. |
57
+ | `env` | `{ islands?: boolean }`{lang="ts"} | `false` | Set this value to `false` if you don't want the plugin to run when rendering server-only or island components. |
58
58
 
59
59
  :video-accordion{title="Watch a video from Alexander Lichter about the Object Syntax for Nuxt plugins" videoId="2aXZyXB1QGQ"}
60
60
 
@@ -8,7 +8,7 @@ links:
8
8
  size: xs
9
9
  ---
10
10
 
11
- Route middleware are stored in the [`app/middleware/`](/docs/4.x/guide/directory-structure/app/middleware) of your Nuxt application (unless [set otherwise](/docs/4.x/api/nuxt-config#middleware)).
11
+ Route middleware are stored in the [`app/middleware/`](/docs/4.x/directory-structure/app/middleware) of your Nuxt application (unless [set otherwise](/docs/4.x/api/nuxt-config#middleware)).
12
12
 
13
13
  ## Type
14
14
 
@@ -39,7 +39,7 @@ You can use route middleware to throw errors and show helpful error messages:
39
39
  ```ts [app/middleware/error.ts]
40
40
  export default defineNuxtRouteMiddleware((to) => {
41
41
  if (to.params.id === '1') {
42
- throw createError({ statusCode: 404, statusMessage: 'Page Not Found' })
42
+ throw createError({ status: 404, statusText: 'Page Not Found' })
43
43
  }
44
44
  })
45
45
  ```
@@ -8,7 +8,7 @@ links:
8
8
  size: xs
9
9
  ---
10
10
 
11
- `definePageMeta` is a compiler macro that you can use to set metadata for your **page** components located in the [`app/pages/`](/docs/4.x/guide/directory-structure/app/pages) directory (unless [set otherwise](/docs/4.x/api/nuxt-config#pages)). This way you can set custom metadata for each static or dynamic route of your Nuxt application.
11
+ `definePageMeta` is a compiler macro that you can use to set metadata for your **page** components located in the [`app/pages/`](/docs/4.x/directory-structure/app/pages) directory (unless [set otherwise](/docs/4.x/api/nuxt-config#pages)). This way you can set custom metadata for each static or dynamic route of your Nuxt application.
12
12
 
13
13
  ```vue [app/pages/some-page.vue]
14
14
  <script setup lang="ts">
@@ -18,7 +18,7 @@ definePageMeta({
18
18
  </script>
19
19
  ```
20
20
 
21
- :read-more{to="/docs/4.x/guide/directory-structure/app/pages#page-metadata"}
21
+ :read-more{to="/docs/4.x/directory-structure/app/pages#page-metadata"}
22
22
 
23
23
  ## Type
24
24
 
@@ -32,6 +32,7 @@ interface PageMeta {
32
32
  path?: string
33
33
  props?: RouteRecordRaw['props']
34
34
  alias?: string | string[]
35
+ groups?: string[]
35
36
  pageTransition?: boolean | TransitionProps
36
37
  layoutTransition?: boolean | TransitionProps
37
38
  viewTransition?: boolean | 'always'
@@ -56,7 +57,7 @@ interface PageMeta {
56
57
 
57
58
  - **Type**: `string`
58
59
 
59
- You may define a name for this page's route. By default, name is generated based on path inside the [`app/pages/` directory](/docs/4.x/guide/directory-structure/app/pages).
60
+ You may define a name for this page's route. By default, name is generated based on path inside the [`app/pages/` directory](/docs/4.x/directory-structure/app/pages).
60
61
 
61
62
  **`path`**
62
63
 
@@ -76,6 +77,12 @@ interface PageMeta {
76
77
 
77
78
  Aliases for the record. Allows defining extra paths that will behave like a copy of the record. Allows having paths shorthands like `/users/:id` and `/u/:id`. All `alias` and `path` values must share the same params.
78
79
 
80
+ **`groups`**
81
+
82
+ - **Type**: `string[]`
83
+
84
+ Route groups the page belongs to, based on the folder structure. Automatically populated for pages within [route groups](/docs/4.x/guide/directory-structure/app/pages#route-groups).
85
+
79
86
  **`keepalive`**
80
87
 
81
88
  - **Type**: `boolean` | [`KeepAliveProps`](https://vuejs.org/api/built-in-components#keepalive)
@@ -104,7 +111,7 @@ interface PageMeta {
104
111
 
105
112
  - **Type**: `MiddlewareKey` | [`NavigationGuard`](https://router.vuejs.org/api/interfaces/navigationguard) | `Array<MiddlewareKey | NavigationGuard>`
106
113
 
107
- Define anonymous or named middleware directly within `definePageMeta`. Learn more about [route middleware](/docs/4.x/guide/directory-structure/app/middleware).
114
+ Define anonymous or named middleware directly within `definePageMeta`. Learn more about [route middleware](/docs/4.x/directory-structure/app/middleware).
108
115
 
109
116
  **`pageTransition`**
110
117
 
@@ -130,7 +137,7 @@ interface PageMeta {
130
137
 
131
138
  - **Type**: `(route: RouteLocationNormalized) => boolean | Promise<boolean> | Partial<NuxtError> | Promise<Partial<NuxtError>>`
132
139
 
133
- Validate whether a given route can validly be rendered with this page. Return true if it is valid, or false if not. If another match can't be found, this will mean a 404. You can also directly return an object with `statusCode`/`statusMessage` to respond immediately with an error (other matches will not be checked).
140
+ Validate whether a given route can validly be rendered with this page. Return true if it is valid, or false if not. If another match can't be found, this will mean a 404. You can also directly return an object with `status`/`statusText` to respond immediately with an error (other matches will not be checked).
134
141
 
135
142
  **`scrollToTop`**
136
143
 
@@ -142,7 +149,7 @@ interface PageMeta {
142
149
 
143
150
  - **Type**: `any`
144
151
 
145
- Apart from the above properties, you can also set **custom** metadata. You may wish to do so in a type-safe way by [augmenting the type of the `meta` object](/docs/4.x/guide/directory-structure/app/pages/#typing-custom-metadata).
152
+ Apart from the above properties, you can also set **custom** metadata. You may wish to do so in a type-safe way by [augmenting the type of the `meta` object](/docs/4.x/directory-structure/app/pages/#typing-custom-metadata).
146
153
 
147
154
  ## Examples
148
155
 
@@ -219,7 +226,7 @@ For more examples see [Vue Router's Matching Syntax](https://router.vuejs.org/gu
219
226
 
220
227
  ### Defining Layout
221
228
 
222
- You can define the layout that matches the layout's file name located (by default) in the [`app/layouts/` directory](/docs/4.x/guide/directory-structure/app/layouts). You can also disable the layout by setting the `layout` to `false`:
229
+ You can define the layout that matches the layout's file name located (by default) in the [`app/layouts/` directory](/docs/4.x/directory-structure/app/layouts). You can also disable the layout by setting the `layout` to `false`:
223
230
 
224
231
  ```vue [app/pages/some-page.vue]
225
232
  <script setup lang="ts">
@@ -68,7 +68,7 @@ export default defineNuxtRouteMiddleware((to, from) => {
68
68
 
69
69
  In this case, `navigateTo` will be executed but not returned, which may lead to unexpected behavior.
70
70
 
71
- :read-more{to="/docs/4.x/guide/directory-structure/app/middleware"}
71
+ :read-more{to="/docs/4.x/directory-structure/app/middleware"}
72
72
 
73
73
  ### Navigating to an External URL
74
74
 
@@ -217,14 +217,14 @@ An object accepting the following properties:
217
217
 
218
218
  - An object accepting the following properties:
219
219
 
220
- | Property | Type | Description |
221
- |----------|---------|--------------|
222
- | `popup` | `boolean` | Requests a minimal popup window instead of a new tab, with UI features decided by the browser. |
223
- | `width` or `innerWidth` | `number` | Specifies the content area's width (minimum 100 pixels), including scrollbars. |
224
- | `height` or `innerHeight` | `number` | Specifies the content area's height (minimum 100 pixels), including scrollbars. |
225
- | `left` or `screenX` | `number` | Sets the horizontal position of the new window relative to the left edge of the screen. |
226
- | `top` or `screenY` | `number` | Sets the vertical position of the new window relative to the top edge of the screen. |
227
- | `noopener` | `boolean` | Prevents the new window from accessing the originating window via `window.opener`. |
228
- | `noreferrer` | `boolean` | Prevents the Referer header from being sent and implicitly enables `noopener`. |
220
+ | Property | Type | Description |
221
+ |---------------------------|-----------|------------------------------------------------------------------------------------------------|
222
+ | `popup` | `boolean` | Requests a minimal popup window instead of a new tab, with UI features decided by the browser. |
223
+ | `width` or `innerWidth` | `number` | Specifies the content area's width (minimum 100 pixels), including scrollbars. |
224
+ | `height` or `innerHeight` | `number` | Specifies the content area's height (minimum 100 pixels), including scrollbars. |
225
+ | `left` or `screenX` | `number` | Sets the horizontal position of the new window relative to the left edge of the screen. |
226
+ | `top` or `screenY` | `number` | Sets the vertical position of the new window relative to the top edge of the screen. |
227
+ | `noopener` | `boolean` | Prevents the new window from accessing the originating window via `window.opener`. |
228
+ | `noreferrer` | `boolean` | Prevents the Referer header from being sent and implicitly enables `noopener`. |
229
229
 
230
230
  Refer to the [documentation](https://developer.mozilla.org/en-US/docs/Web/API/Window/open#windowfeatures) for more detailed information on the **windowFeatures** properties.
@@ -1,8 +1,6 @@
1
1
  ---
2
2
  title: "refreshCookie"
3
3
  description: "Refresh useCookie values manually when a cookie has changed"
4
- navigation:
5
- badge: New
6
4
  links:
7
5
  - label: Source
8
6
  icon: i-simple-icons-github
@@ -19,6 +19,42 @@ export default defineNuxtRouteMiddleware((to) => {
19
19
  })
20
20
  ```
21
21
 
22
+ ## Passing Props to Layouts
23
+
24
+ You can pass props to the layout by providing an object as the second argument:
25
+
26
+ ```ts [app/middleware/admin-layout.ts]
27
+ export default defineNuxtRouteMiddleware((to) => {
28
+ setPageLayout('admin', {
29
+ sidebar: true,
30
+ title: 'Dashboard',
31
+ })
32
+ })
33
+ ```
34
+
35
+ The layout can then receive these props:
36
+
37
+ ```vue [app/layouts/admin.vue]
38
+ <script setup lang="ts">
39
+ const props = defineProps<{
40
+ sidebar?: boolean
41
+ title?: string
42
+ }>()
43
+ </script>
44
+
45
+ <template>
46
+ <div>
47
+ <aside v-if="sidebar">
48
+ Sidebar
49
+ </aside>
50
+ <main>
51
+ <h1>{{ title }}</h1>
52
+ <slot />
53
+ </main>
54
+ </div>
55
+ </template>
56
+ ```
57
+
22
58
  ::note
23
59
  If you choose to set the layout dynamically on the server side, you _must_ do so before the layout is rendered by Vue (that is, within a plugin or route middleware) to avoid a hydration mismatch.
24
60
  ::
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: 'setResponseStatus'
3
- description: setResponseStatus sets the statusCode (and optionally the statusMessage) of the response.
3
+ description: setResponseStatus sets the status (and optionally the statusText) of the response.
4
4
  links:
5
5
  - label: Source
6
6
  icon: i-simple-icons-github
@@ -10,7 +10,7 @@ links:
10
10
 
11
11
  Nuxt provides composables and utilities for first-class server-side-rendering support.
12
12
 
13
- `setResponseStatus` sets the statusCode (and optionally the statusMessage) of the response.
13
+ `setResponseStatus` sets the status (and optionally the statusText) of the response.
14
14
 
15
15
  ::important
16
16
  `setResponseStatus` can only be called in the [Nuxt context](/docs/4.x/guide/going-further/nuxt-app#the-nuxt-context).