@nuxt/docs-nightly 4.2.1-29360927.606ef13e → 4.2.1-29362163.2a087817
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.
- package/1.getting-started/02.installation.md +2 -2
- package/1.getting-started/03.configuration.md +4 -4
- package/1.getting-started/04.views.md +2 -2
- package/1.getting-started/05.assets.md +1 -1
- package/1.getting-started/06.styling.md +11 -11
- package/1.getting-started/09.transitions.md +6 -6
- package/1.getting-started/10.data-fetching.md +14 -14
- package/1.getting-started/11.state-management.md +2 -2
- package/1.getting-started/12.error-handling.md +4 -4
- package/1.getting-started/13.server.md +4 -4
- package/1.getting-started/14.layers.md +1 -1
- package/1.getting-started/17.testing.md +3 -3
- package/1.getting-started/18.upgrade.md +3 -3
- package/2.guide/1.directory-structure/1.app/1.components.md +4 -4
- package/2.guide/1.directory-structure/1.app/1.composables.md +1 -1
- package/2.guide/1.directory-structure/1.app/1.layouts.md +2 -2
- package/2.guide/1.directory-structure/1.app/1.middleware.md +4 -4
- package/2.guide/1.directory-structure/1.app/1.pages.md +13 -13
- package/2.guide/1.directory-structure/1.app/1.plugins.md +1 -1
- package/2.guide/1.directory-structure/1.node_modules.md +1 -1
- package/2.guide/1.directory-structure/1.public.md +1 -1
- package/2.guide/1.directory-structure/1.server.md +2 -2
- package/2.guide/1.directory-structure/2.env.md +1 -1
- package/2.guide/2.concepts/1.auto-imports.md +2 -2
- package/2.guide/2.concepts/10.nuxt-lifecycle.md +3 -3
- package/2.guide/2.concepts/2.vuejs-development.md +3 -3
- package/2.guide/2.concepts/3.rendering.md +4 -4
- package/2.guide/2.concepts/7.esm.md +2 -2
- package/2.guide/2.concepts/9.code-style.md +1 -1
- package/2.guide/3.going-further/1.experimental-features.md +6 -6
- package/2.guide/3.going-further/1.features.md +1 -1
- package/2.guide/3.going-further/1.internals.md +2 -2
- package/2.guide/3.going-further/2.hooks.md +1 -1
- package/2.guide/3.going-further/3.modules.md +2 -2
- package/2.guide/3.going-further/6.nuxt-app.md +5 -5
- package/2.guide/3.going-further/7.layers.md +2 -2
- package/2.guide/3.going-further/9.debugging.md +1 -1
- package/2.guide/4.recipes/1.custom-routing.md +4 -4
- package/2.guide/4.recipes/3.custom-usefetch.md +1 -1
- package/2.guide/5.best-practices/hydration.md +1 -1
- package/3.api/1.components/10.nuxt-picture.md +1 -1
- package/3.api/1.components/11.teleports.md +1 -1
- package/3.api/1.components/12.nuxt-route-announcer.md +1 -1
- package/3.api/1.components/2.nuxt-page.md +1 -1
- package/3.api/1.components/4.nuxt-link.md +11 -11
- package/3.api/1.components/5.nuxt-loading-indicator.md +1 -1
- package/3.api/1.components/6.nuxt-error-boundary.md +1 -1
- package/3.api/2.composables/use-app-config.md +1 -1
- package/3.api/2.composables/use-async-data.md +74 -11
- package/3.api/2.composables/use-cookie.md +6 -6
- package/3.api/2.composables/use-fetch.md +1 -1
- package/3.api/2.composables/use-nuxt-app.md +7 -7
- package/3.api/2.composables/use-nuxt-data.md +1 -1
- package/3.api/2.composables/use-request-fetch.md +1 -1
- package/3.api/2.composables/use-route.md +1 -1
- package/3.api/2.composables/use-router.md +15 -15
- package/3.api/2.composables/use-state.md +1 -1
- package/3.api/3.utils/abort-navigation.md +2 -2
- package/3.api/3.utils/define-lazy-hydration-component.md +4 -4
- package/3.api/3.utils/define-nuxt-component.md +1 -1
- package/3.api/3.utils/define-nuxt-plugin.md +1 -1
- package/3.api/3.utils/define-nuxt-route-middleware.md +1 -1
- package/3.api/3.utils/define-page-meta.md +8 -8
- package/3.api/3.utils/navigate-to.md +4 -4
- package/3.api/3.utils/on-before-route-leave.md +1 -1
- package/3.api/3.utils/on-before-route-update.md +1 -1
- package/3.api/3.utils/refresh-cookie.md +1 -1
- package/3.api/3.utils/update-app-config.md +2 -2
- package/3.api/5.kit/1.modules.md +2 -2
- package/3.api/5.kit/14.builder.md +6 -6
- package/3.api/6.advanced/1.hooks.md +5 -5
- package/3.api/6.nuxt-config.md +24 -24
- package/5.community/4.contribution.md +1 -1
- package/5.community/5.framework-contribution.md +8 -8
- package/5.community/6.roadmap.md +3 -3
- package/6.bridge/4.plugins-and-middleware.md +1 -1
- package/7.migration/2.configuration.md +2 -2
- package/7.migration/20.module-authors.md +1 -1
- package/7.migration/5.plugins-and-middleware.md +1 -1
- package/7.migration/6.pages-and-layouts.md +2 -2
- package/README.md +1 -1
- package/package.json +1 -1
|
@@ -6,12 +6,12 @@ navigation.icon: i-vscode-icons-folder-type-view
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
::note
|
|
9
|
-
To reduce your application's bundle size, this directory is **optional**, meaning that [`vue-router`](https://router.vuejs.org) won't be included if you only use [`app.vue`](/docs/4.x/guide/directory-structure/app). To force the pages system, set `pages: true` in `nuxt.config` or have a [`router.options.ts`](/docs/4.x/guide/recipes/custom-routing#using-routeroptions).
|
|
9
|
+
To reduce your application's bundle size, this directory is **optional**, meaning that [`vue-router`](https://router.vuejs.org) won't be included if you only use [`app.vue`](/docs/4.x/guide/directory-structure/app/app). To force the pages system, set `pages: true` in `nuxt.config` or have a [`router.options.ts`](/docs/4.x/guide/recipes/custom-routing#using-routeroptions).
|
|
10
10
|
::
|
|
11
11
|
|
|
12
12
|
## Usage
|
|
13
13
|
|
|
14
|
-
Pages are Vue components and can have any [valid extension](/docs/4.x/api/
|
|
14
|
+
Pages are Vue components and can have any [valid extension](/docs/4.x/api/nuxt-config#extensions) that Nuxt supports (by default `.vue`, `.js`, `.jsx`, `.mjs`, `.ts` or `.tsx`).
|
|
15
15
|
|
|
16
16
|
Nuxt will automatically create a route for every page in your `~/pages/` directory.
|
|
17
17
|
|
|
@@ -46,7 +46,7 @@ export default defineComponent({
|
|
|
46
46
|
|
|
47
47
|
The `app/pages/index.vue` file will be mapped to the `/` route of your application.
|
|
48
48
|
|
|
49
|
-
If you are using [`app.vue`](/docs/4.x/guide/directory-structure/app), make sure to use the [`<NuxtPage/>`](/docs/4.x/api/components/nuxt-page) component to display the current page:
|
|
49
|
+
If you are using [`app.vue`](/docs/4.x/guide/directory-structure/app/app), make sure to use the [`<NuxtPage/>`](/docs/4.x/api/components/nuxt-page) component to display the current page:
|
|
50
50
|
|
|
51
51
|
```vue [app/app.vue]
|
|
52
52
|
<template>
|
|
@@ -93,7 +93,7 @@ Here are some examples to illustrate what a page with a single root element look
|
|
|
93
93
|
|
|
94
94
|
## Dynamic Routes
|
|
95
95
|
|
|
96
|
-
If you place anything within square brackets, it will be turned into a [dynamic route](https://router.vuejs.org/guide/essentials/dynamic-matching
|
|
96
|
+
If you place anything within square brackets, it will be turned into a [dynamic route](https://router.vuejs.org/guide/essentials/dynamic-matching) parameter. You can mix and match multiple parameters and even non-dynamic text within a file name or directory.
|
|
97
97
|
|
|
98
98
|
If you want a parameter to be _optional_, you must enclose it in double square brackets - for example, `~/pages/[[slug]]/index.vue` or `~/pages/[[slug]].vue` will match both `/` and `/test`.
|
|
99
99
|
|
|
@@ -154,7 +154,7 @@ Navigating to `/hello/world` would render:
|
|
|
154
154
|
|
|
155
155
|
## Nested Routes
|
|
156
156
|
|
|
157
|
-
It is possible to display [nested routes](https://
|
|
157
|
+
It is possible to display [nested routes](https://router.vuejs.org/guide/essentials/nested-routes) with `<NuxtPage>`.
|
|
158
158
|
|
|
159
159
|
Example:
|
|
160
160
|
|
|
@@ -268,9 +268,9 @@ console.log(route.meta.title) // My home page
|
|
|
268
268
|
</script>
|
|
269
269
|
```
|
|
270
270
|
|
|
271
|
-
If you are using nested routes, the page metadata from all these routes will be merged into a single object. For more on route meta, see the [vue-router docs](https://router.vuejs.org/guide/advanced/meta
|
|
271
|
+
If you are using nested routes, the page metadata from all these routes will be merged into a single object. For more on route meta, see the [vue-router docs](https://router.vuejs.org/guide/advanced/meta).
|
|
272
272
|
|
|
273
|
-
Much like `defineEmits` or `defineProps` (see [Vue docs](https://vuejs.org/api/sfc-script-setup
|
|
273
|
+
Much like `defineEmits` or `defineProps` (see [Vue docs](https://vuejs.org/api/sfc-script-setup#defineprops-defineemits)), `definePageMeta` is a **compiler macro**. It will be compiled away so you cannot reference it within your component. Instead, the metadata passed to it will be hoisted out of the component.
|
|
274
274
|
Therefore, the page meta object cannot reference the component. However, it can reference imported bindings, as well as locally defined **pure functions**.
|
|
275
275
|
|
|
276
276
|
::warning
|
|
@@ -301,13 +301,13 @@ Of course, you are welcome to define metadata for your own use throughout your a
|
|
|
301
301
|
|
|
302
302
|
#### `alias`
|
|
303
303
|
|
|
304
|
-
You can define page aliases. They allow you to access the same page from different paths. It can be either a string or an array of strings as defined [in the vue-router documentation](https://router.vuejs.org/guide/essentials/redirect-and-alias
|
|
304
|
+
You can define page aliases. They allow you to access the same page from different paths. It can be either a string or an array of strings as defined [in the vue-router documentation](https://router.vuejs.org/guide/essentials/redirect-and-alias#Alias).
|
|
305
305
|
|
|
306
306
|
#### `keepalive`
|
|
307
307
|
|
|
308
|
-
Nuxt will automatically wrap your page in [the Vue `<KeepAlive>` component](https://vuejs.org/guide/built-ins/keep-alive
|
|
308
|
+
Nuxt will automatically wrap your page in [the Vue `<KeepAlive>` component](https://vuejs.org/guide/built-ins/keep-alive#keepalive) if you set `keepalive: true` in your `definePageMeta`. This might be useful to do, for example, in a parent route that has dynamic child routes, if you want to preserve page state across route changes.
|
|
309
309
|
|
|
310
|
-
When your goal is to preserve state for parent routes use this syntax: `<NuxtPage keepalive />`. You can also set props to be passed to `<KeepAlive>` (see [a full list](https://vuejs.org/api/built-in-components
|
|
310
|
+
When your goal is to preserve state for parent routes use this syntax: `<NuxtPage keepalive />`. You can also set props to be passed to `<KeepAlive>` (see [a full list](https://vuejs.org/api/built-in-components#keepalive)).
|
|
311
311
|
|
|
312
312
|
You can set a default value for this property [in your `nuxt.config`](/docs/4.x/api/nuxt-config#keepalive).
|
|
313
313
|
|
|
@@ -321,13 +321,13 @@ You can define the layout used to render the route. This can be either false (to
|
|
|
321
321
|
|
|
322
322
|
#### `layoutTransition` and `pageTransition`
|
|
323
323
|
|
|
324
|
-
You can define transition properties for the `<transition>` component that wraps your pages and layouts, or pass `false` to disable the `<transition>` wrapper for that route. You can see [a list of options that can be passed](https://vuejs.org/api/built-in-components
|
|
324
|
+
You can define transition properties for the `<transition>` component that wraps your pages and layouts, or pass `false` to disable the `<transition>` wrapper for that route. You can see [a list of options that can be passed](https://vuejs.org/api/built-in-components#transition) or read [more about how transitions work](https://vuejs.org/guide/built-ins/transition#transition).
|
|
325
325
|
|
|
326
326
|
You can set default values for these properties [in your `nuxt.config`](/docs/4.x/api/nuxt-config#layouttransition).
|
|
327
327
|
|
|
328
328
|
#### `middleware`
|
|
329
329
|
|
|
330
|
-
You can define middleware to apply before loading this page. It will be merged with all the other middleware used in any matching parent/child routes. It can be a string, a function (an anonymous/inlined middleware function following [the global before guard pattern](https://router.vuejs.org/guide/advanced/navigation-guards
|
|
330
|
+
You can define middleware to apply before loading this page. It will be merged with all the other middleware used in any matching parent/child routes. It can be a string, a function (an anonymous/inlined middleware function following [the global before guard pattern](https://router.vuejs.org/guide/advanced/navigation-guards#Global-Before-Guards)), or an array of strings/functions. [More about named middleware](/docs/4.x/guide/directory-structure/app/middleware).
|
|
331
331
|
|
|
332
332
|
#### `name`
|
|
333
333
|
|
|
@@ -335,7 +335,7 @@ You may define a name for this page's route.
|
|
|
335
335
|
|
|
336
336
|
#### `path`
|
|
337
337
|
|
|
338
|
-
You may define a path matcher, if you have a more complex pattern than can be expressed with the file name. See [the `vue-router` docs](https://router.vuejs.org/guide/essentials/route-matching-syntax
|
|
338
|
+
You may define a path matcher, if you have a more complex pattern than can be expressed with the file name. See [the `vue-router` docs](https://router.vuejs.org/guide/essentials/route-matching-syntax#Custom-regex-in-params) for more information.
|
|
339
339
|
|
|
340
340
|
#### `props`
|
|
341
341
|
|
|
@@ -205,7 +205,7 @@ Note that we highly recommend using [`composables`](/docs/4.x/guide/directory-st
|
|
|
205
205
|
|
|
206
206
|
::warning
|
|
207
207
|
**If your plugin provides a `ref` or `computed`, it will not be unwrapped in a component `<template>`.** :br
|
|
208
|
-
This is due to how Vue works with refs that aren't top-level to the template. You can read more about it [in the Vue documentation](https://vuejs.org/guide/essentials/reactivity-fundamentals
|
|
208
|
+
This is due to how Vue works with refs that aren't top-level to the template. You can read more about it [in the Vue documentation](https://vuejs.org/guide/essentials/reactivity-fundamentals#caveat-when-unwrapping-in-templates).
|
|
209
209
|
::
|
|
210
210
|
|
|
211
211
|
## Typing Plugins
|
|
@@ -5,7 +5,7 @@ head.title: "node_modules/"
|
|
|
5
5
|
navigation.icon: i-vscode-icons-folder-type-node
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
The package manager ([`npm`](https://docs.npmjs.com/cli/commands/npm) or [`yarn`](https://yarnpkg.com) or [`pnpm`](https://pnpm.io/cli/install) or [`bun`](https://bun.
|
|
8
|
+
The package manager ([`npm`](https://docs.npmjs.com/cli/commands/npm) or [`yarn`](https://yarnpkg.com) or [`pnpm`](https://pnpm.io/cli/install) or [`bun`](https://bun.com/package-manager)) creates this directory to store the dependencies of your project.
|
|
9
9
|
|
|
10
10
|
::important
|
|
11
11
|
This directory should be added to your [`.gitignore`](/docs/4.x/guide/directory-structure/gitignore) file to avoid pushing the dependencies to your repository.
|
|
@@ -22,6 +22,6 @@ useSeoMeta({
|
|
|
22
22
|
</script>
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
::tip{to="https://v2.nuxt.com/docs/directory-structure/static" target="_blank"}
|
|
25
|
+
::tip{to="https://v2.nuxt.com/docs/directory-structure/static/" target="_blank"}
|
|
26
26
|
This is known as the [`static/`] directory in Nuxt 2.
|
|
27
27
|
::
|
|
@@ -158,7 +158,7 @@ You can now universally call this API on `/api/hello/nuxt` and get `Hello, nuxt!
|
|
|
158
158
|
|
|
159
159
|
### Matching HTTP Method
|
|
160
160
|
|
|
161
|
-
Handle file names can be suffixed with `.get`, `.post`, `.put`, `.delete`, ... to match request's [HTTP Method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods).
|
|
161
|
+
Handle file names can be suffixed with `.get`, `.post`, `.put`, `.delete`, ... to match request's [HTTP Method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Methods).
|
|
162
162
|
|
|
163
163
|
```ts [server/api/test.get.ts]
|
|
164
164
|
export default defineEventHandler(() => 'Test get handler')
|
|
@@ -226,7 +226,7 @@ export default defineEventHandler(async (event) => {
|
|
|
226
226
|
})
|
|
227
227
|
```
|
|
228
228
|
|
|
229
|
-
::tip{to="https://unjs.io/blog/2023-08-15-h3-towards-the-edge-of-the-web
|
|
229
|
+
::tip{to="https://unjs.io/blog/2023-08-15-h3-towards-the-edge-of-the-web/#runtime-type-safe-request-utils"}
|
|
230
230
|
Alternatively, use `readValidatedBody` with a schema validator such as Zod for runtime and type safety.
|
|
231
231
|
::
|
|
232
232
|
|
|
@@ -75,5 +75,5 @@ Note that for a purely static site, it is not possible to set runtime configurat
|
|
|
75
75
|
|
|
76
76
|
::note
|
|
77
77
|
If you want to use environment variables set at build time but do not care about updating these down the line (or only need to update them reactively _within_ your app) then `appConfig` may be a better choice. You can define `appConfig` both within your `nuxt.config` (using environment variables) and also within an `~/app.config.ts` file in your project.
|
|
78
|
-
:read-more{to="/docs/4.x/guide/directory-structure/app-config"}
|
|
78
|
+
:read-more{to="/docs/4.x/guide/directory-structure/app/app-config"}
|
|
79
79
|
::
|
|
@@ -3,7 +3,7 @@ title: Auto-imports
|
|
|
3
3
|
description: "Nuxt auto-imports components, composables, helper functions and Vue APIs."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
Nuxt auto-imports components, composables and [Vue.js APIs](https://vuejs.org/api) to use across your application without explicitly importing them.
|
|
6
|
+
Nuxt auto-imports components, composables and [Vue.js APIs](https://vuejs.org/api/) to use across your application without explicitly importing them.
|
|
7
7
|
|
|
8
8
|
```vue twoslash [app/app.vue]
|
|
9
9
|
<script setup lang="ts">
|
|
@@ -109,7 +109,7 @@ Nuxt directly auto-imports files created in defined directories:
|
|
|
109
109
|
|
|
110
110
|
::warning
|
|
111
111
|
**Auto-imported `ref` and `computed` won't be unwrapped in a component `<template>`.** :br
|
|
112
|
-
This is due to how Vue works with refs that aren't top-level to the template. You can read more about it [in the Vue documentation](https://vuejs.org/guide/essentials/reactivity-fundamentals
|
|
112
|
+
This is due to how Vue works with refs that aren't top-level to the template. You can read more about it [in the Vue documentation](https://vuejs.org/guide/essentials/reactivity-fundamentals#caveat-when-unwrapping-in-templates).
|
|
113
113
|
::
|
|
114
114
|
|
|
115
115
|
### Explicit Imports
|
|
@@ -40,13 +40,13 @@ The Vue and Nuxt instances are created first. Afterward, Nuxt executes its serve
|
|
|
40
40
|
- Built-in plugins, such as Vue Router and `unhead`.
|
|
41
41
|
- Custom plugins located in the `app/plugins/` directory, including those without a suffix (e.g., `myPlugin.ts`) and those with the `.server` suffix (e.g., `myServerPlugin.server.ts`).
|
|
42
42
|
|
|
43
|
-
Plugins execute in a specific order and may have dependencies on one another. For more details, including execution order and parallelism, refer to the [Plugins documentation](/docs/4.x/guide/directory-structure/plugins).
|
|
43
|
+
Plugins execute in a specific order and may have dependencies on one another. For more details, including execution order and parallelism, refer to the [Plugins documentation](/docs/4.x/guide/directory-structure/app/plugins).
|
|
44
44
|
|
|
45
45
|
::callout{icon="i-lucide-lightbulb"}
|
|
46
46
|
After this step, Nuxt calls the [`app:created`](/docs/4.x/api/advanced/hooks#app-hooks-runtime) hook, which can be used to execute additional logic.
|
|
47
47
|
::
|
|
48
48
|
|
|
49
|
-
:read-more{to="/docs/4.x/guide/directory-structure/plugins"}
|
|
49
|
+
:read-more{to="/docs/4.x/guide/directory-structure/app/plugins"}
|
|
50
50
|
|
|
51
51
|
### Step 4: Route Validation
|
|
52
52
|
|
|
@@ -120,7 +120,7 @@ Custom plugins in the `app/plugins/` directory, such as those without a suffix (
|
|
|
120
120
|
After this step, Nuxt calls the [`app:created`](/docs/4.x/api/advanced/hooks#app-hooks-runtime) hook, which can be used to execute additional logic.
|
|
121
121
|
::
|
|
122
122
|
|
|
123
|
-
:read-more{to="/docs/4.x/guide/directory-structure/plugins"}
|
|
123
|
+
:read-more{to="/docs/4.x/guide/directory-structure/app/plugins"}
|
|
124
124
|
|
|
125
125
|
### Step 2: Route Validation
|
|
126
126
|
|
|
@@ -21,7 +21,7 @@ We chose to build Nuxt on top of Vue for these reasons:
|
|
|
21
21
|
|
|
22
22
|
### Single File Components
|
|
23
23
|
|
|
24
|
-
[Vue’s single-file components](https://vuejs.org/guide/scaling-up/sfc
|
|
24
|
+
[Vue’s single-file components](https://vuejs.org/guide/scaling-up/sfc) (SFC or `*.vue` files) encapsulate the markup (`<template>`), logic (`<script>`) and styling (`<style>`) of a Vue component. Nuxt provides a zero-config experience for SFCs with [Hot Module Replacement](https://vite.dev/guide/features#hot-module-replacement) that offers a seamless developer experience.
|
|
25
25
|
|
|
26
26
|
### Auto-imports
|
|
27
27
|
|
|
@@ -78,7 +78,7 @@ export default {
|
|
|
78
78
|
</script>
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
The [Composition API](https://vuejs.org/guide/extras/composition-api-faq
|
|
81
|
+
The [Composition API](https://vuejs.org/guide/extras/composition-api-faq) introduced in Vue 3 is not a replacement of the Options API, but it enables better logic reuse throughout an application, and is a more natural way to group code by concern in complex components.
|
|
82
82
|
|
|
83
83
|
Used with the `setup` keyword in the `<script>` definition, here is the above component rewritten with Composition API and Nuxt 3’s auto-imported Reactivity APIs:
|
|
84
84
|
|
|
@@ -91,7 +91,7 @@ const increment = () => count.value++
|
|
|
91
91
|
|
|
92
92
|
The goal of Nuxt is to provide a great developer experience around the Composition API.
|
|
93
93
|
|
|
94
|
-
- Use auto-imported [Reactivity functions](https://vuejs.org/api/reactivity-core
|
|
94
|
+
- Use auto-imported [Reactivity functions](https://vuejs.org/api/reactivity-core) from Vue and Nuxt [built-in composables](/docs/4.x/api/composables/use-async-data).
|
|
95
95
|
- Write your own auto-imported reusable functions in the [`app/composables/` directory](/docs/4.x/guide/directory-structure/app/composables).
|
|
96
96
|
|
|
97
97
|
### TypeScript Support
|
|
@@ -44,7 +44,7 @@ const handleClick = () => {
|
|
|
44
44
|
|
|
45
45
|
On the initial request, the `counter` ref is initialized in the server since it is rendered inside the `<p>` tag. The contents of `handleClick` is never executed here. During hydration in the browser, the `counter` ref is re-initialized. The `handleClick` finally binds itself to the button; Therefore it is reasonable to deduce that the body of `handleClick` will always run in a browser environment.
|
|
46
46
|
|
|
47
|
-
[Middlewares](/docs/4.x/guide/directory-structure/app/middleware) and [pages](/docs/4.x/guide/directory-structure/app/pages) run in the server and on the client during hydration. [Plugins](/docs/4.x/guide/directory-structure/plugins) can be rendered on the server or client or both. [Components](/docs/4.x/guide/directory-structure/app/components) can be forced to run on the client only as well. [Composables](/docs/4.x/guide/directory-structure/app/composables) and [utilities](/docs/4.x/guide/directory-structure/app/utils) are rendered based on the context of their usage.
|
|
47
|
+
[Middlewares](/docs/4.x/guide/directory-structure/app/middleware) and [pages](/docs/4.x/guide/directory-structure/app/pages) run in the server and on the client during hydration. [Plugins](/docs/4.x/guide/directory-structure/app/plugins) can be rendered on the server or client or both. [Components](/docs/4.x/guide/directory-structure/app/components) can be forced to run on the client only as well. [Composables](/docs/4.x/guide/directory-structure/app/composables) and [utilities](/docs/4.x/guide/directory-structure/app/utils) are rendered based on the context of their usage.
|
|
48
48
|
|
|
49
49
|
**Benefits of server-side rendering:**
|
|
50
50
|
- **Performance**: Users can get immediate access to the page's content because browsers can display static content much faster than JavaScript-generated content. At the same time, Nuxt preserves the interactivity of a web application during the hydration process.
|
|
@@ -57,7 +57,7 @@ On the initial request, the `counter` ref is initialized in the server since it
|
|
|
57
57
|
Universal rendering is very versatile and can fit almost any use case, and is especially appropriate for any content-oriented websites: **blogs, marketing websites, portfolios, e-commerce sites, and marketplaces.**
|
|
58
58
|
|
|
59
59
|
::tip
|
|
60
|
-
For more examples about writing Vue code without hydration mismatch, see [the Vue docs](https://vuejs.org/guide/scaling-up/ssr
|
|
60
|
+
For more examples about writing Vue code without hydration mismatch, see [the Vue docs](https://vuejs.org/guide/scaling-up/ssr#hydration-mismatch).
|
|
61
61
|
::
|
|
62
62
|
|
|
63
63
|
::important
|
|
@@ -225,8 +225,8 @@ Edge-side rendering is possible thanks to [Nitro](https://nitro.build/), the [se
|
|
|
225
225
|
|
|
226
226
|
The current platforms where you can leverage ESR are:
|
|
227
227
|
- [Cloudflare Pages](https://pages.cloudflare.com) with zero configuration using the git integration and the `nuxt build` command
|
|
228
|
-
- [Vercel
|
|
229
|
-
- [Netlify Edge Functions](https://www.netlify.com/
|
|
228
|
+
- [Vercel Cloud](https://vercel.com/home) using the `nuxt build` command and `NITRO_PRESET=vercel-edge` environment variable
|
|
229
|
+
- [Netlify Edge Functions](https://www.netlify.com/platform/#netlify-edge-functions) using the `nuxt build` command and `NITRO_PRESET=netlify-edge` environment variable
|
|
230
230
|
|
|
231
231
|
Note that **Hybrid Rendering** can be used when using Edge-Side Rendering with route rules.
|
|
232
232
|
|
|
@@ -31,7 +31,7 @@ export { a }
|
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
Before ECMAScript Modules (ESM) became a standard (it took more than 10 years!), tooling like
|
|
34
|
-
[webpack](https://webpack.js.org/guides/ecma-script-modules) and even languages like TypeScript started supporting so-called **ESM syntax**.
|
|
34
|
+
[webpack](https://webpack.js.org/guides/ecma-script-modules/) and even languages like TypeScript started supporting so-called **ESM syntax**.
|
|
35
35
|
However, there are some key differences with actual spec; here's [a helpful explainer](https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/).
|
|
36
36
|
|
|
37
37
|
### What is 'Native' ESM?
|
|
@@ -161,7 +161,7 @@ const pkg = require('cjs-pkg')
|
|
|
161
161
|
console.log(pkg) // { test: 123 }
|
|
162
162
|
```
|
|
163
163
|
|
|
164
|
-
[Node.js in native ESM mode](https://nodejs.org/api/esm.html#interoperability-with-commonjs), [typescript with `esModuleInterop` enabled](https://www.typescriptlang.org/tsconfig
|
|
164
|
+
[Node.js in native ESM mode](https://nodejs.org/api/esm.html#interoperability-with-commonjs), [typescript with `esModuleInterop` enabled](https://www.typescriptlang.org/tsconfig/#esModuleInterop) and bundlers such as webpack, provide a compatibility mechanism so that we can default import such library.
|
|
165
165
|
This mechanism is often referred to as "interop require default":
|
|
166
166
|
|
|
167
167
|
```js
|
|
@@ -8,7 +8,7 @@ description: "Nuxt supports ESLint out of the box"
|
|
|
8
8
|
The recommended approach for Nuxt is to enable ESLint support using the [`@nuxt/eslint`](https://eslint.nuxt.com/packages/module) module, that will setup project-aware ESLint configuration for you.
|
|
9
9
|
|
|
10
10
|
:::callout{icon="i-lucide-lightbulb"}
|
|
11
|
-
The module is designed for the [new ESLint flat config format](https://eslint.org/docs/latest/use/configure/configuration-files
|
|
11
|
+
The module is designed for the [new ESLint flat config format](https://eslint.org/docs/latest/use/configure/configuration-files) which is the [default format since ESLint v9](https://eslint.org/blog/2024/04/eslint-v9.0.0-released/). If you are using the legacy `.eslintrc` config, you will need to [configure manually with `@nuxt/eslint-config`](https://eslint.nuxt.com/packages/config#customizing-the-config). We highly recommend you to migrate over the flat config to be future-proof.
|
|
12
12
|
:::
|
|
13
13
|
|
|
14
14
|
## Quick Setup
|
|
@@ -5,7 +5,7 @@ description: "Enable Nuxt experimental features to unlock new possibilities."
|
|
|
5
5
|
|
|
6
6
|
Nuxt includes experimental features that you can enable in your configuration file.
|
|
7
7
|
|
|
8
|
-
Internally, Nuxt uses `@nuxt/schema` to define these experimental features. You can refer to the [API documentation](/docs/4.x/
|
|
8
|
+
Internally, Nuxt uses `@nuxt/schema` to define these experimental features. You can refer to the [API documentation](/docs/4.x/guide/going-further/experimental-features) or the [source code](https://github.com/nuxt/nuxt/blob/main/packages/schema/src/config/experimental.ts) for more information.
|
|
9
9
|
|
|
10
10
|
::note
|
|
11
11
|
Note that these features are experimental and could be removed or modified in the future.
|
|
@@ -290,7 +290,7 @@ export default defineNuxtConfig({
|
|
|
290
290
|
|
|
291
291
|
:link-example{to="https://stackblitz.com/edit/nuxt-view-transitions?file=app.vue" target="_blank"}
|
|
292
292
|
|
|
293
|
-
::read-more{icon="i-simple-icons-mdnwebdocs" to="https://developer.mozilla.org/en-US/docs/Web/API/
|
|
293
|
+
::read-more{icon="i-simple-icons-mdnwebdocs" to="https://developer.mozilla.org/en-US/docs/Web/API/View_Transition_API" target="_blank"}
|
|
294
294
|
Read more about the **View Transition API**.
|
|
295
295
|
::
|
|
296
296
|
|
|
@@ -405,12 +405,12 @@ should do this automatically for you.)
|
|
|
405
405
|
// This would be unsafe in a dynamic page (e.g. `[slug].vue`) because the route slug makes a difference
|
|
406
406
|
// to the data fetched, but Nuxt can't know that because it's not reflected in the key.
|
|
407
407
|
const route = useRoute()
|
|
408
|
-
const { data } = await useAsyncData(async () => {
|
|
409
|
-
return await $fetch(`/api/my-page/${route.params.slug}
|
|
408
|
+
const { data } = await useAsyncData(async (_nuxtApp, { signal }) => {
|
|
409
|
+
return await $fetch(`/api/my-page/${route.params.slug}`, { signal })
|
|
410
410
|
})
|
|
411
411
|
// Instead, you should use a key that uniquely identifies the data fetched.
|
|
412
|
-
const { data } = await useAsyncData(route.params.slug, async () => {
|
|
413
|
-
return await $fetch(`/api/my-page/${route.params.slug}
|
|
412
|
+
const { data } = await useAsyncData(route.params.slug, async (_nuxtApp, { signal }) => {
|
|
413
|
+
return await $fetch(`/api/my-page/${route.params.slug}`, { signal })
|
|
414
414
|
})
|
|
415
415
|
```
|
|
416
416
|
|
|
@@ -91,7 +91,7 @@ export default defineNuxtConfig({
|
|
|
91
91
|
|
|
92
92
|
### typescriptBundlerResolution
|
|
93
93
|
|
|
94
|
-
This enables 'Bundler' module resolution mode for TypeScript, which is the recommended setting for frameworks like Nuxt and [Vite](https://vite.dev/guide/performance
|
|
94
|
+
This enables 'Bundler' module resolution mode for TypeScript, which is the recommended setting for frameworks like Nuxt and [Vite](https://vite.dev/guide/performance#reduce-resolve-operations).
|
|
95
95
|
|
|
96
96
|
It improves type support when using modern libraries with `exports`.
|
|
97
97
|
|
|
@@ -30,7 +30,7 @@ Global usage is possible for the browser but not on the server, to avoid sharing
|
|
|
30
30
|
|
|
31
31
|
Since [`useNuxtApp`](/docs/4.x/api/composables/use-nuxt-app) throws an exception if context is currently unavailable, if your composable does not always require `nuxtApp`, you can use [`tryUseNuxtApp`](/docs/4.x/api/composables/use-nuxt-app#tryusenuxtapp) instead, which will return `null` instead of throwing an exception.
|
|
32
32
|
|
|
33
|
-
To extend the `nuxtApp` interface and hook into different stages or access contexts, we can use [Nuxt Plugins](/docs/4.x/guide/directory-structure/plugins).
|
|
33
|
+
To extend the `nuxtApp` interface and hook into different stages or access contexts, we can use [Nuxt Plugins](/docs/4.x/guide/directory-structure/app/plugins).
|
|
34
34
|
|
|
35
35
|
Check [Nuxt App](/docs/4.x/api/composables/use-nuxt-app) for more information about this interface.
|
|
36
36
|
|
|
@@ -76,6 +76,6 @@ Nuxt builds and bundles project using Node.js but also has a runtime side.
|
|
|
76
76
|
|
|
77
77
|
While both areas can be extended, that runtime context is isolated from build-time. Therefore, they are not supposed to share state, code, or context other than runtime configuration!
|
|
78
78
|
|
|
79
|
-
`nuxt.config` and [Nuxt Modules](/docs/4.x/guide/going-further/modules) can be used to extend the build context, and [Nuxt Plugins](/docs/4.x/guide/directory-structure/plugins) can be used to extend runtime.
|
|
79
|
+
`nuxt.config` and [Nuxt Modules](/docs/4.x/guide/going-further/modules) can be used to extend the build context, and [Nuxt Plugins](/docs/4.x/guide/directory-structure/app/plugins) can be used to extend runtime.
|
|
80
80
|
|
|
81
81
|
When building an application for production, `nuxt build` will generate a standalone build in the `.output` directory, independent of `nuxt.config` and [Nuxt modules](/docs/4.x/guide/going-further/modules).
|
|
@@ -39,7 +39,7 @@ Explore all available Nuxt hooks.
|
|
|
39
39
|
|
|
40
40
|
## App Hooks (Runtime)
|
|
41
41
|
|
|
42
|
-
App hooks can be mainly used by [Nuxt Plugins](/docs/4.x/guide/directory-structure/plugins) to hook into rendering lifecycle but could also be used in Vue composables.
|
|
42
|
+
App hooks can be mainly used by [Nuxt Plugins](/docs/4.x/guide/directory-structure/app/plugins) to hook into rendering lifecycle but could also be used in Vue composables.
|
|
43
43
|
|
|
44
44
|
```ts [app/plugins/test.ts]
|
|
45
45
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
@@ -224,7 +224,7 @@ Modules, like everything in a Nuxt configuration, aren't included in your applic
|
|
|
224
224
|
Inside the runtime directory, you can provide any kind of assets related to the Nuxt App:
|
|
225
225
|
- Vue components
|
|
226
226
|
- Composables
|
|
227
|
-
- [Nuxt plugins](/docs/4.x/guide/directory-structure/plugins)
|
|
227
|
+
- [Nuxt plugins](/docs/4.x/guide/directory-structure/app/plugins)
|
|
228
228
|
|
|
229
229
|
To the [server engine](/docs/4.x/guide/concepts/server-engine), Nitro:
|
|
230
230
|
- API routes
|
|
@@ -876,7 +876,7 @@ Watch Vue School video about Nuxt module types.
|
|
|
876
876
|
|
|
877
877
|
### Module Types
|
|
878
878
|
|
|
879
|
-
**Official modules** are modules prefixed (scoped) with `@nuxt/` (e.g. [`@nuxt/content`](https://content.
|
|
879
|
+
**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!
|
|
880
880
|
|
|
881
881
|
**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.
|
|
882
882
|
|
|
@@ -9,7 +9,7 @@ links:
|
|
|
9
9
|
|
|
10
10
|
In Nuxt, you can access runtime app context within composables, components and plugins.
|
|
11
11
|
|
|
12
|
-
::read-more{to="https://v2.nuxt.com/docs/internals-glossary/context
|
|
12
|
+
::read-more{to="https://v2.nuxt.com/docs/internals-glossary/context/#the-context" target="_blank"}
|
|
13
13
|
In Nuxt 2, this was referred to as **Nuxt context**.
|
|
14
14
|
::
|
|
15
15
|
|
|
@@ -23,7 +23,7 @@ Jump over the `NuxtApp` interface documentation.
|
|
|
23
23
|
|
|
24
24
|
Many composables and utilities, both built-in and user-made, may require access to the Nuxt instance. This doesn't exist everywhere on your application, because a fresh instance is created on every request.
|
|
25
25
|
|
|
26
|
-
Currently, the Nuxt context is only accessible in [plugins](/docs/4.x/guide/directory-structure/plugins), [Nuxt hooks](/docs/4.x/guide/going-further/hooks), [Nuxt middleware](/docs/4.x/guide/directory-structure/app/middleware) (if wrapped in `defineNuxtRouteMiddleware`), and [setup functions](https://vuejs.org/api/composition-api-setup
|
|
26
|
+
Currently, the Nuxt context is only accessible in [plugins](/docs/4.x/guide/directory-structure/app/plugins), [Nuxt hooks](/docs/4.x/guide/going-further/hooks), [Nuxt middleware](/docs/4.x/guide/directory-structure/app/middleware) (if wrapped in `defineNuxtRouteMiddleware`), and [setup functions](https://vuejs.org/api/composition-api-setup) (in pages and components).
|
|
27
27
|
|
|
28
28
|
If a composable is called without access to the context, you may get an error stating that 'A composable that requires access to the Nuxt instance was called outside of a plugin, Nuxt hook, Nuxt middleware, or Vue setup function.' In that case, you can also explicitly call functions within this context by using [`nuxtApp.runWithContext`](/docs/4.x/api/composables/use-nuxt-app#runwithcontext).
|
|
29
29
|
|
|
@@ -42,7 +42,7 @@ If your composable does not always need `nuxtApp` or you simply want to check if
|
|
|
42
42
|
|
|
43
43
|
Plugins also receive `nuxtApp` as the first argument for convenience.
|
|
44
44
|
|
|
45
|
-
:read-more{to="/docs/4.x/guide/directory-structure/plugins"}
|
|
45
|
+
:read-more{to="/docs/4.x/guide/directory-structure/app/plugins"}
|
|
46
46
|
|
|
47
47
|
## Providing Helpers
|
|
48
48
|
|
|
@@ -55,10 +55,10 @@ nuxtApp.provide('hello', name => `Hello ${name}!`)
|
|
|
55
55
|
console.log(nuxtApp.$hello('name')) // Prints "Hello name!"
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
::read-more{to="/docs/4.x/guide/directory-structure/plugins#providing-helpers"}
|
|
58
|
+
::read-more{to="/docs/4.x/guide/directory-structure/app/plugins#providing-helpers"}
|
|
59
59
|
It is possible to inject helpers by returning an object with a `provide` key in plugins.
|
|
60
60
|
::
|
|
61
61
|
|
|
62
|
-
::read-more{to="https://v2.nuxt.com/docs/directory-structure/plugins
|
|
62
|
+
::read-more{to="https://v2.nuxt.com/docs/directory-structure/plugins/#inject-in-root--context" target="_blank"}
|
|
63
63
|
In Nuxt 2 plugins, this was referred to as **inject function**.
|
|
64
64
|
::
|
|
@@ -20,9 +20,9 @@ Additionally, certain other files in the layer directory will be auto-scanned an
|
|
|
20
20
|
- [`app/layouts/*`](/docs/4.x/guide/directory-structure/app/layouts) - Extend the default layouts
|
|
21
21
|
- [`app/middleware/*`](/docs/4.x/guide/directory-structure/app/middleware) - Extend the default middleware
|
|
22
22
|
- [`app/pages/*`](/docs/4.x/guide/directory-structure/app/pages) - Extend the default pages
|
|
23
|
-
- [`app/plugins/*`](/docs/4.x/guide/directory-structure/plugins) - Extend the default plugins
|
|
23
|
+
- [`app/plugins/*`](/docs/4.x/guide/directory-structure/app/plugins) - Extend the default plugins
|
|
24
24
|
- [`app/utils/*`](/docs/4.x/guide/directory-structure/app/utils) - Extend the default utils
|
|
25
|
-
- [`app/app.config.ts`](/docs/4.x/guide/directory-structure/app-config) - Extend the default app config
|
|
25
|
+
- [`app/app.config.ts`](/docs/4.x/guide/directory-structure/app/app-config) - Extend the default app config
|
|
26
26
|
- [`server/*`](/docs/4.x/guide/directory-structure/server) - Extend the default server endpoints & middleware
|
|
27
27
|
- [`nuxt.config.ts`](/docs/4.x/guide/directory-structure/nuxt-config)- Extend the default nuxt config
|
|
28
28
|
|
|
@@ -36,7 +36,7 @@ It is possible to debug your Nuxt app in your IDE while you are developing it.
|
|
|
36
36
|
|
|
37
37
|
### Example VS Code Debug Configuration
|
|
38
38
|
|
|
39
|
-
You may need to update the config below with a path to your web browser. For more information, visit the [VS Code documentation about debug configuration](https://
|
|
39
|
+
You may need to update the config below with a path to your web browser. For more information, visit the [VS Code documentation about debug configuration](https://code.visualstudio.com/docs/debugtest/debugging#_launch-configurations).
|
|
40
40
|
|
|
41
41
|
```json5
|
|
42
42
|
{
|
|
@@ -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
|
|
20
|
+
// https://router.vuejs.org/api/interfaces/routeroptions#routes
|
|
21
21
|
routes: _routes => [
|
|
22
22
|
{
|
|
23
23
|
name: 'home',
|
|
@@ -81,13 +81,13 @@ The [Nuxt kit](/docs/4.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
|
|
84
|
+
On top of customizing options for [`vue-router`](https://router.vuejs.org/api/interfaces/routeroptions), Nuxt offers [additional options](/docs/4.x/api/nuxt-config#router) to customize the router.
|
|
85
85
|
|
|
86
86
|
### Using `router.options`
|
|
87
87
|
|
|
88
88
|
This is the recommended way to specify [router options](/docs/4.x/api/nuxt-config#router).
|
|
89
89
|
|
|
90
|
-
```ts [router.options.ts]
|
|
90
|
+
```ts [app/router.options.ts]
|
|
91
91
|
import type { RouterConfig } from '@nuxt/schema'
|
|
92
92
|
|
|
93
93
|
export default {
|
|
@@ -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
|
|
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
|
```
|
|
@@ -12,7 +12,7 @@ However, Nuxt provides a way to create a custom fetcher for your API (or multipl
|
|
|
12
12
|
|
|
13
13
|
## Custom `$fetch`
|
|
14
14
|
|
|
15
|
-
Let's create a custom `$fetch` instance with a [Nuxt plugin](/docs/4.x/guide/directory-structure/plugins).
|
|
15
|
+
Let's create a custom `$fetch` instance with a [Nuxt plugin](/docs/4.x/guide/directory-structure/app/plugins).
|
|
16
16
|
|
|
17
17
|
::note
|
|
18
18
|
`$fetch` is a configured instance of [ofetch](https://github.com/unjs/ofetch) which supports adding the base URL of your Nuxt server as well as direct function calls during SSR (avoiding HTTP roundtrips).
|
|
@@ -184,5 +184,5 @@ onMounted(() => {
|
|
|
184
184
|
4. **Avoid side effects in setup**: Move browser-dependent code to `onMounted`
|
|
185
185
|
|
|
186
186
|
::tip
|
|
187
|
-
You can read the [Vue documentation on SSR hydration mismatch](https://vuejs.org/guide/scaling-up/ssr
|
|
187
|
+
You can read the [Vue documentation on SSR hydration mismatch](https://vuejs.org/guide/scaling-up/ssr#hydration-mismatch) for a better understanding of hydration.
|
|
188
188
|
::
|
|
@@ -12,7 +12,7 @@ links:
|
|
|
12
12
|
|
|
13
13
|
Usage of `<NuxtPicture>` is almost identical to [`<NuxtImg>`](/docs/4.x/api/components/nuxt-img) but it also allows serving modern formats like `webp` when possible.
|
|
14
14
|
|
|
15
|
-
Learn more about the [`<picture>` tag on MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/
|
|
15
|
+
Learn more about the [`<picture>` tag on MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/picture).
|
|
16
16
|
|
|
17
17
|
## Setup
|
|
18
18
|
|
|
@@ -4,7 +4,7 @@ description: The <Teleport> component teleports a component to a different locat
|
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
::warning
|
|
7
|
-
The `to` target of [`<Teleport>`](https://vuejs.org/guide/built-ins/teleport
|
|
7
|
+
The `to` target of [`<Teleport>`](https://vuejs.org/guide/built-ins/teleport) expects a CSS selector string or an actual DOM node. Nuxt currently has SSR support for teleports to `#teleports` only, with client-side support for other targets using a `<ClientOnly>` wrapper.
|
|
8
8
|
::
|
|
9
9
|
|
|
10
10
|
## Body Teleport
|
|
@@ -16,7 +16,7 @@ This component is available in Nuxt v3.12+.
|
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
18
18
|
|
|
19
|
-
Add `<NuxtRouteAnnouncer/>` in your [`app.vue`](/docs/4.x/guide/directory-structure/app) or [`app/layouts/`](/docs/4.x/guide/directory-structure/app/layouts) to enhance accessibility by informing assistive technologies about page title changes. This ensures that navigational changes are announced to users relying on screen readers.
|
|
19
|
+
Add `<NuxtRouteAnnouncer/>` in your [`app.vue`](/docs/4.x/guide/directory-structure/app/app) or [`app/layouts/`](/docs/4.x/guide/directory-structure/app/layouts) to enhance accessibility by informing assistive technologies about page title changes. This ensures that navigational changes are announced to users relying on screen readers.
|
|
20
20
|
|
|
21
21
|
```vue [app/app.vue]
|
|
22
22
|
<template>
|
|
@@ -11,7 +11,7 @@ links:
|
|
|
11
11
|
`<NuxtPage>` is a built-in component that comes with Nuxt. It lets you display top-level or nested pages located in the [`app/pages/`](/docs/4.x/guide/directory-structure/app/pages) directory.
|
|
12
12
|
|
|
13
13
|
::note
|
|
14
|
-
`<NuxtPage>` is a wrapper around [`<RouterView>`](https://router.vuejs.org/api/interfaces/
|
|
14
|
+
`<NuxtPage>` is a wrapper around [`<RouterView>`](https://router.vuejs.org/api/interfaces/routerviewprops) from Vue Router. It should be used instead of `<RouterView>` because the former takes additional care of internal states. Otherwise, `useRoute()` may return incorrect paths.
|
|
15
15
|
::
|
|
16
16
|
|
|
17
17
|
`<NuxtPage>` includes the following components:
|