@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
@@ -0,0 +1,104 @@
1
+ ---
2
+ title: "Follow Best Practices"
3
+ description: "Build performant and maintainable Nuxt modules with these guidelines."
4
+ ---
5
+
6
+ With great power comes great responsibility. While modules are powerful, here are some best practices to keep in mind while authoring modules to keep applications performant and developer experience great.
7
+
8
+ ## Handle Async Setup
9
+
10
+ As we've seen, Nuxt modules can be asynchronous. For example, you may want to develop a module that needs fetching some API or calling an async function.
11
+
12
+ However, be careful with asynchronous behaviors as Nuxt will wait for your module to setup before going to the next module and starting the development server, build process, etc. Prefer deferring time-consuming logic to Nuxt hooks.
13
+
14
+ ::warning
15
+ If your module takes more than **1 second** to setup, Nuxt will emit a warning about it.
16
+ ::
17
+
18
+ ## Prefix Your Exports
19
+
20
+ Nuxt modules should provide an explicit prefix for any exposed configuration, plugin, API, composable, component, or server route to avoid conflicts with other modules, Nuxt internals, or user-defined code.
21
+
22
+ Ideally, prefix them with your module's name. For example, if your module is called `nuxt-foo`:
23
+
24
+ | Type | ❌ Avoid | ✅ Prefer |
25
+ | --- | --- | --- |
26
+ | Components | `<Button>`, `<Modal>` | `<FooButton>`, `<FooModal>` |
27
+ | Composables | `useData()`, `useModal()` | `useFooData()`, `useFooModal()` |
28
+ | Server routes | `/api/track`, `/api/data` | `/api/_foo/track`, `/api/_foo/data` |
29
+
30
+ ### Server Routes
31
+
32
+ This is particularly important for server routes, where common paths like `/api/auth`, `/api/login`, or `/api/user` are very likely already used by the application.
33
+
34
+ Use a unique prefix based on your module name:
35
+ - `/api/_foo/...` (using underscore prefix)
36
+ - `/_foo/...` (for non-API routes)
37
+
38
+ ## Use Lifecycle Hooks
39
+
40
+ When your module needs to perform one-time setup tasks (like generating configuration files, setting up databases, or installing dependencies), use lifecycle hooks instead of running the logic in your main `setup` function.
41
+
42
+ ```ts
43
+ import { addServerHandler, defineNuxtModule } from 'nuxt/kit'
44
+ import semver from 'semver'
45
+
46
+ export default defineNuxtModule({
47
+ meta: {
48
+ name: 'my-database-module',
49
+ version: '1.0.0',
50
+ },
51
+ async onInstall (nuxt) {
52
+ // One-time setup: create database schema, generate config files, etc.
53
+ await generateDatabaseConfig(nuxt.options.rootDir)
54
+ },
55
+ async onUpgrade (nuxt, options, previousVersion) {
56
+ // Handle version-specific migrations
57
+ if (semver.lt(previousVersion, '1.0.0')) {
58
+ await migrateLegacyData()
59
+ }
60
+ },
61
+ setup (options, nuxt) {
62
+ // Regular setup logic that runs on every build
63
+ addServerHandler({ /* ... */ })
64
+ },
65
+ })
66
+ ```
67
+
68
+ This pattern prevents unnecessary work on every build and provides a better developer experience. See the [lifecycle hooks documentation](/docs/3.x/api/kit/modules#using-lifecycle-hooks-for-module-installation-and-upgrade) for more details.
69
+
70
+ ## Be TypeScript Friendly
71
+
72
+ Nuxt has first-class TypeScript integration for the best developer experience.
73
+
74
+ Exposing types and using TypeScript to develop modules benefits users even when not using TypeScript directly.
75
+
76
+ ## Use ESM Syntax
77
+
78
+ Nuxt relies on native ESM. Please read [Native ES Modules](/docs/3.x/guide/concepts/esm) for more information.
79
+
80
+ ## Document Your Module
81
+
82
+ Consider documenting module usage in the readme file:
83
+
84
+ - Why use this module?
85
+ - How to use this module?
86
+ - What does this module do?
87
+
88
+ Linking to the integration website and documentation is always a good idea.
89
+
90
+ ## Provide a Demo
91
+
92
+ It's a good practice to make a minimal reproduction with your module and [StackBlitz](https://nuxt.new/s/v4) that you add to your module readme.
93
+
94
+ This not only provides potential users of your module a quick and easy way to experiment with the module but also an easy way for them to build minimal reproductions they can send you when they encounter issues.
95
+
96
+ ## Stay Version Agnostic
97
+
98
+ Nuxt, Nuxt Kit, and other new toolings are made to have both forward and backward compatibility in mind.
99
+
100
+ Please use "X for Nuxt" instead of "X for Nuxt 3" to avoid fragmentation in the ecosystem and prefer using `meta.compatibility` to set Nuxt version constraints.
101
+
102
+ ## Follow Starter Conventions
103
+
104
+ The module starter comes with a default set of tools and configurations (e.g. ESLint configuration). If you plan on open-sourcing your module, sticking with those defaults ensures your module shares a consistent coding style with other [community modules](/modules) out there, making it easier for others to contribute.
@@ -0,0 +1,32 @@
1
+ ---
2
+ title: "Publish & Share Your Module"
3
+ description: "Join the Nuxt module ecosystem and publish your module to npm."
4
+ ---
5
+
6
+ The [Nuxt module ecosystem](/modules) represents more than 35 million monthly NPM downloads and provides extended functionalities and integrations with all sort of tools. You can be part of this ecosystem!
7
+
8
+ ::tip{icon="i-lucide-video" to="https://vueschool.io/lessons/exploring-nuxt-modules-ecosystem-and-module-types?friend=nuxt" target="_blank"}
9
+ Watch Vue School video about Nuxt module types.
10
+ ::
11
+
12
+ ## Understand Module Types
13
+
14
+ **Official modules** are modules prefixed (scoped) with `@nuxt/` (e.g. [`@nuxt/content`](https://content.nuxt.com)). They are made and maintained actively by the Nuxt team. Like with the framework, contributions from the community are more than welcome to help make them better!
15
+
16
+ **Community modules** are modules prefixed (scoped) with `@nuxtjs/` (e.g. [`@nuxtjs/tailwindcss`](https://tailwindcss.nuxtjs.org)). They are proven modules made and maintained by community members. Again, contributions are welcome from anyone.
17
+
18
+ **Third-party and other community modules** are modules (often) prefixed with `nuxt-`. Anyone can make them, using this prefix allows these modules to be discoverable on npm. This is the best starting point to draft and try an idea!
19
+
20
+ **Private or personal modules** are modules made for your own use case or company. They don't need to follow any naming rules to work with Nuxt and are often seen scoped under an npm organization (e.g. `@my-company/nuxt-auth`)
21
+
22
+ ## List Your Module
23
+
24
+ Any community modules are welcome to be listed on [the module list](/modules). To be listed, [open an issue in the nuxt/modules](https://github.com/nuxt/modules/issues/new?template=module_request.yml) repository. The Nuxt team can help you to apply best practices before listing.
25
+
26
+ ## Join nuxt-modules
27
+
28
+ By moving your modules to [nuxt-modules](https://github.com/nuxt-modules), there is always someone else to help, and this way, we can join forces to make one perfect solution.
29
+
30
+ If you have an already published and working module, and want to transfer it to `nuxt-modules`, [open an issue in nuxt/modules](https://github.com/nuxt/modules/issues/new).
31
+
32
+ By joining `nuxt-modules` we can rename your community module under the `@nuxtjs/` scope and provide a subdomain (e.g. `my-module.nuxtjs.org`) for its documentation.
@@ -0,0 +1,36 @@
1
+ ---
2
+ title: 'Module Author Guide'
3
+ titleTemplate: '%s'
4
+ description: 'Learn how to create a Nuxt module to integrate, enhance or extend any Nuxt applications.'
5
+ navigation: false
6
+ surround: false
7
+ ---
8
+
9
+ Nuxt's [configuration](/docs/3.x/api/nuxt-config) and [hooks](/docs/3.x/guide/going-further/hooks) systems make it possible to customize every aspect of Nuxt and add any integration you might need (Vue plugins, CMS, server routes, components, logging, etc.).
10
+
11
+ **Nuxt modules** are functions that sequentially run when starting Nuxt in development mode using `nuxt dev` or building a project for production with `nuxt build`.
12
+ With modules, you can encapsulate, properly test, and share custom solutions as npm packages without adding unnecessary boilerplate to your project, or requiring changes to Nuxt itself.
13
+
14
+ ::card-group{class="sm:grid-cols-1"}
15
+ ::card{icon="i-lucide-rocket" title="Create Your First Module" to="/docs/3.x/guide/modules/getting-started"}
16
+ Learn how to create your first Nuxt module using the official starter template.
17
+ ::
18
+ ::card{icon="i-lucide-box" title="Understand Module Structure" to="/docs/3.x/guide/modules/module-anatomy"}
19
+ Learn how Nuxt modules are structured and how to define them.
20
+ ::
21
+ ::card{icon="i-lucide-code" title="Add Plugins, Components & More" to="/docs/3.x/guide/modules/recipes-basics"}
22
+ Learn how to inject plugins, components, composables and server routes from your module.
23
+ ::
24
+ ::card{icon="i-lucide-layers" title="Use Hooks & Extend Types" to="/docs/3.x/guide/modules/recipes-advanced"}
25
+ Master lifecycle hooks, virtual files and TypeScript declarations in your modules.
26
+ ::
27
+ ::card{icon="i-lucide-test-tube" title="Test Your Module" to="/docs/3.x/guide/modules/testing"}
28
+ Learn how to test your Nuxt module with unit, integration and E2E tests.
29
+ ::
30
+ ::card{icon="i-lucide-medal" title="Follow Best Practices" to="/docs/3.x/guide/modules/best-practices"}
31
+ Build performant and maintainable Nuxt modules with these guidelines.
32
+ ::
33
+ ::card{icon="i-lucide-globe" title="Publish & Share Your Module" to="/docs/3.x/guide/modules/ecosystem"}
34
+ Join the Nuxt module ecosystem and publish your module to npm.
35
+ ::
36
+ ::
@@ -17,7 +17,7 @@ If it returns `null` or `undefined`, Nuxt will fall back to the default routes (
17
17
  import type { RouterConfig } from '@nuxt/schema'
18
18
 
19
19
  export default {
20
- // https://router.vuejs.org/api/interfaces/routeroptions.html#routes
20
+ // https://router.vuejs.org/api/interfaces/routeroptions#routes
21
21
  routes: _routes => [
22
22
  {
23
23
  name: 'home',
@@ -81,7 +81,7 @@ The [Nuxt kit](/docs/3.x/guide/going-further/kit) provides a few ways [to add ro
81
81
 
82
82
  ## Router Options
83
83
 
84
- On top of customizing options for [`vue-router`](https://router.vuejs.org/api/interfaces/routeroptions.html), Nuxt offers [additional options](/docs/3.x/api/nuxt-config#router) to customize the router.
84
+ On top of customizing options for [`vue-router`](https://router.vuejs.org/api/interfaces/routeroptions), Nuxt offers [additional options](/docs/3.x/api/nuxt-config#router) to customize the router.
85
85
 
86
86
  ### Using `app/router.options`
87
87
 
@@ -175,7 +175,7 @@ import type { RouterConfig } from '@nuxt/schema'
175
175
  import { createMemoryHistory } from 'vue-router'
176
176
 
177
177
  export default {
178
- // https://router.vuejs.org/api/interfaces/routeroptions.html
178
+ // https://router.vuejs.org/api/interfaces/routeroptions
179
179
  history: base => import.meta.client ? createMemoryHistory(base) : null, /* default */
180
180
  } satisfies RouterConfig
181
181
  ```
@@ -26,6 +26,10 @@ First, we need to install the Vite plugin, for our example, we'll use `@rollup/p
26
26
  bun add @rollup/plugin-yaml
27
27
  ```
28
28
 
29
+ ```bash [deno]
30
+ deno add npm:@rollup/plugin-yaml
31
+ ```
32
+
29
33
  ::
30
34
 
31
35
  Next, we need to import and add it to our [`nuxt.config.ts`](/docs/3.x/directory-structure/nuxt-config) file:
@@ -98,7 +98,7 @@ import type { UseFetchOptions } from 'nuxt/app'
98
98
 
99
99
  interface CustomError {
100
100
  message: string
101
- statusCode: number
101
+ status: number
102
102
  }
103
103
 
104
104
  export function useAPI<T> (
@@ -116,7 +116,7 @@ export function useAPI<T> (
116
116
  This example demonstrates how to use a custom `useFetch`, but the same structure is identical for a custom `useAsyncData`.
117
117
  ::
118
118
 
119
- :link-example{to="/docs/examples/advanced/use-custom-fetch-composable"}
119
+ :link-example{to="/docs/3.x/examples/advanced/use-custom-fetch-composable"}
120
120
 
121
121
  :video-accordion{title="Watch a video about custom $fetch and Repository Pattern in Nuxt" videoId="jXH8Tr-exhI"}
122
122
 
@@ -65,7 +65,7 @@ export default defineEventHandler(async (event) => {
65
65
  return {}
66
66
  }
67
67
  throw createError({
68
- statusCode: 401,
68
+ status: 401,
69
69
  message: 'Bad credentials',
70
70
  })
71
71
  })
@@ -155,7 +155,7 @@ export default defineEventHandler(async (event) => {
155
155
 
156
156
  ## Protect App Routes
157
157
 
158
- Our data is safe with the server-side route in place, but without doing anything else, unauthenticated users would probably get some odd data when trying to access the `/users` page. We should create a [client-side middleware](https://nuxt.com/docs/guide/directory-structure/middleware) to protect the route on the client side and redirect users to the login page.
158
+ Our data is safe with the server-side route in place, but without doing anything else, unauthenticated users would probably get some odd data when trying to access the `/users` page. We should create a [client-side middleware](https://nuxt.com/docs/3.x/directory-structure/middleware) to protect the route on the client side and redirect users to the login page.
159
159
 
160
160
  `nuxt-auth-utils` provides a convenient `useUserSession` composable which we'll use to check if the user is logged in, and redirect them if they are not.
161
161
 
@@ -1,10 +1,9 @@
1
1
  ---
2
- title: "Events"
2
+ title: "Creating Custom Events"
3
3
  description: "Nuxt provides a powerful event system powered by hookable."
4
+ navigation.title: "Custom Events"
4
5
  ---
5
6
 
6
- # Events
7
-
8
7
  Using events is a great way to decouple your application and allow for more flexible and modular communication between different parts of your code. Events can have multiple listeners that do not depend on each other. For example, you may wish to send an email to your user each time an order has shipped. Instead of coupling your order processing code to your email code, you can emit an event which a listener can receive and use to dispatch an email.
9
8
 
10
9
  The Nuxt event system is powered by [unjs/hookable](https://github.com/unjs/hookable), which is the same library that powers the Nuxt hooks system.
@@ -58,6 +57,6 @@ await nuxtApp.callHook('app:user:registered', {
58
57
  You can inspect all events using the **Nuxt DevTools** Hooks panel.
59
58
  ::
60
59
 
61
- ::read-more{to="/docs/guide/going-further/hooks"}
60
+ ::read-more{to="/docs/3.x/guide/going-further/hooks"}
62
61
  Learn more about Nuxt's built-in hooks and how to extend them
63
62
  ::