@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
|
@@ -244,21 +244,21 @@ export default defineNuxtConfig({
|
|
|
244
244
|
|
|
245
245
|
### RouterLink
|
|
246
246
|
|
|
247
|
-
When not using `external`, `<NuxtLink>` supports all Vue Router's [`RouterLink` props](https://router.vuejs.org/api/interfaces/
|
|
247
|
+
When not using `external`, `<NuxtLink>` supports all Vue Router's [`RouterLink` props](https://router.vuejs.org/api/interfaces/routerlinkprops)
|
|
248
248
|
|
|
249
|
-
- `to`: Any URL or a [route location object](https://router.vuejs.org/api/type-aliases/
|
|
250
|
-
- `custom`: Whether `<NuxtLink>` should wrap its content in an `<a>` element. It allows taking full control of how a link is rendered and how navigation works when it is clicked. Works the same as [Vue Router's `custom` prop](https://router.vuejs.org/api/interfaces/
|
|
251
|
-
- `exactActiveClass`: A class to apply on exact active links. Works the same as [Vue Router's `exactActiveClass` prop](https://router.vuejs.org/api/interfaces/
|
|
252
|
-
- `activeClass`: A class to apply on active links. Works the same as [Vue Router's `activeClass` prop](https://router.vuejs.org/api/interfaces/
|
|
253
|
-
- `replace`: Works the same as [Vue Router's `replace` prop](https://router.vuejs.org/api/interfaces/
|
|
254
|
-
- `ariaCurrentValue`: An `aria-current` attribute value to apply on exact active links. Works the same as [Vue Router's `ariaCurrentValue` prop](https://router.vuejs.org/api/interfaces/
|
|
249
|
+
- `to`: Any URL or a [route location object](https://router.vuejs.org/api/type-aliases/routelocation) from Vue Router
|
|
250
|
+
- `custom`: Whether `<NuxtLink>` should wrap its content in an `<a>` element. It allows taking full control of how a link is rendered and how navigation works when it is clicked. Works the same as [Vue Router's `custom` prop](https://router.vuejs.org/api/interfaces/routerlinkprops#custom-)
|
|
251
|
+
- `exactActiveClass`: A class to apply on exact active links. Works the same as [Vue Router's `exactActiveClass` prop](https://router.vuejs.org/api/interfaces/routerlinkprops#exactActiveClass-) on internal links. Defaults to Vue Router's default (`"router-link-exact-active"`)
|
|
252
|
+
- `activeClass`: A class to apply on active links. Works the same as [Vue Router's `activeClass` prop](https://router.vuejs.org/api/interfaces/routerlinkprops#activeClass-) on internal links. Defaults to Vue Router's default (`"router-link-active"`)
|
|
253
|
+
- `replace`: Works the same as [Vue Router's `replace` prop](https://router.vuejs.org/api/interfaces/routelocationoptions#replace-) on internal links
|
|
254
|
+
- `ariaCurrentValue`: An `aria-current` attribute value to apply on exact active links. Works the same as [Vue Router's `ariaCurrentValue` prop](https://router.vuejs.org/api/interfaces/routerlinkprops#ariaCurrentValue-) on internal links
|
|
255
255
|
|
|
256
256
|
### NuxtLink
|
|
257
257
|
|
|
258
258
|
- `href`: An alias for `to`. If used with `to`, `href` will be ignored
|
|
259
259
|
- `noRel`: If set to `true`, no `rel` attribute will be added to the external link
|
|
260
260
|
- `external`: Forces the link to be rendered as an `<a>` tag instead of a Vue Router `RouterLink`.
|
|
261
|
-
- `prefetch`: When enabled will prefetch middleware, layouts and payloads (when using [payloadExtraction](/docs/4.x/
|
|
261
|
+
- `prefetch`: When enabled will prefetch middleware, layouts and payloads (when using [payloadExtraction](/docs/4.x/guide/going-further/experimental-features#payloadextraction)) of links in the viewport. Used by the experimental [crossOriginPrefetch](/docs/4.x/guide/going-further/experimental-features#crossoriginprefetch) config.
|
|
262
262
|
- `prefetchOn`: Allows custom control of when to prefetch links. Possible options are `interaction` and `visibility` (default). You can also pass an object for full control, for example: `{ interaction: true, visibility: true }`. This prop is only used when `prefetch` is enabled (default) and `noPrefetch` is not set.
|
|
263
263
|
- `noPrefetch`: Disables prefetching.
|
|
264
264
|
- `prefetchedClass`: A class to apply to links that have been prefetched.
|
|
@@ -276,7 +276,7 @@ Defaults can be overwritten, see [overwriting defaults](/docs/4.x/api/components
|
|
|
276
276
|
|
|
277
277
|
### In Nuxt Config
|
|
278
278
|
|
|
279
|
-
You can overwrite some `<NuxtLink>` defaults in your [`nuxt.config`](/docs/4.x/
|
|
279
|
+
You can overwrite some `<NuxtLink>` defaults in your [`nuxt.config`](/docs/4.x/guide/going-further/experimental-features#defaults)
|
|
280
280
|
|
|
281
281
|
::important
|
|
282
282
|
These options will likely be moved elsewhere in the future, such as into `app.config` or into the `app/` directory.
|
|
@@ -336,8 +336,8 @@ function defineNuxtLink (options: NuxtLinkOptions): Component {}
|
|
|
336
336
|
|
|
337
337
|
- `componentName`: A name for the component. Default is `NuxtLink`.
|
|
338
338
|
- `externalRelAttribute`: A default `rel` attribute value applied on external links. Defaults to `"noopener noreferrer"`. Set it to `""` to disable
|
|
339
|
-
- `activeClass`: A default class to apply on active links. Works the same as [Vue Router's `linkActiveClass` option](https://router.vuejs.org/api/interfaces/
|
|
340
|
-
- `exactActiveClass`: A default class to apply on exact active links. Works the same as [Vue Router's `linkExactActiveClass` option](https://router.vuejs.org/api/interfaces/
|
|
339
|
+
- `activeClass`: A default class to apply on active links. Works the same as [Vue Router's `linkActiveClass` option](https://router.vuejs.org/api/interfaces/routeroptions#linkActiveClass-). Defaults to Vue Router's default (`"router-link-active"`)
|
|
340
|
+
- `exactActiveClass`: A default class to apply on exact active links. Works the same as [Vue Router's `linkExactActiveClass` option](https://router.vuejs.org/api/interfaces/routeroptions#linkExactActiveClass-). Defaults to Vue Router's default (`"router-link-exact-active"`)
|
|
341
341
|
- `trailingSlash`: An option to either add or remove trailing slashes in the `href`. If unset or not matching the valid values `append` or `remove`, it will be ignored.
|
|
342
342
|
- `prefetch`: Whether or not to prefetch links by default.
|
|
343
343
|
- `prefetchOn`: Granular control of which prefetch strategies to apply by default.
|
|
@@ -10,7 +10,7 @@ links:
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
Add `<NuxtLoadingIndicator/>` in your [`app.vue`](/docs/4.x/guide/directory-structure/app) or [`app/layouts/`](/docs/4.x/guide/directory-structure/app/layouts).
|
|
13
|
+
Add `<NuxtLoadingIndicator/>` in your [`app.vue`](/docs/4.x/guide/directory-structure/app/app) or [`app/layouts/`](/docs/4.x/guide/directory-structure/app/layouts).
|
|
14
14
|
|
|
15
15
|
```vue [app/app.vue]
|
|
16
16
|
<template>
|
|
@@ -9,7 +9,7 @@ links:
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
::tip
|
|
12
|
-
The `<NuxtErrorBoundary>` uses Vue's [`onErrorCaptured`](https://vuejs.org/api/composition-api-lifecycle
|
|
12
|
+
The `<NuxtErrorBoundary>` uses Vue's [`onErrorCaptured`](https://vuejs.org/api/composition-api-lifecycle#onerrorcaptured) hook under the hood.
|
|
13
13
|
::
|
|
14
14
|
|
|
15
15
|
## Events
|
|
@@ -18,9 +18,9 @@ Within your pages, components, and plugins you can use useAsyncData to get acces
|
|
|
18
18
|
|
|
19
19
|
```vue [app/pages/index.vue]
|
|
20
20
|
<script setup lang="ts">
|
|
21
|
-
const { data, status, error, refresh, clear } = await useAsyncData(
|
|
21
|
+
const { data, status, pending, error, refresh, clear } = await useAsyncData(
|
|
22
22
|
'mountains',
|
|
23
|
-
() => $fetch('https://api.nuxtjs.dev/mountains'),
|
|
23
|
+
(_nuxtApp, { signal }) => $fetch('https://api.nuxtjs.dev/mountains', { signal }),
|
|
24
24
|
)
|
|
25
25
|
</script>
|
|
26
26
|
```
|
|
@@ -30,7 +30,7 @@ If you're using a custom useAsyncData wrapper, do not await it in the composable
|
|
|
30
30
|
::
|
|
31
31
|
|
|
32
32
|
::note
|
|
33
|
-
`data`, `status` and `error` are Vue refs and they should be accessed with `.value` when used within the `<script setup>`, while `refresh`/`execute` and `clear` are plain functions.
|
|
33
|
+
`data`, `status`, `pending` and `error` are Vue refs and they should be accessed with `.value` when used within the `<script setup>`, while `refresh`/`execute` and `clear` are plain functions.
|
|
34
34
|
::
|
|
35
35
|
|
|
36
36
|
### Watch Params
|
|
@@ -42,10 +42,11 @@ The built-in `watch` option allows automatically rerunning the fetcher function
|
|
|
42
42
|
const page = ref(1)
|
|
43
43
|
const { data: posts } = await useAsyncData(
|
|
44
44
|
'posts',
|
|
45
|
-
() => $fetch('https://fakeApi.com/posts', {
|
|
45
|
+
(_nuxtApp, { signal }) => $fetch('https://fakeApi.com/posts', {
|
|
46
46
|
params: {
|
|
47
47
|
page: page.value,
|
|
48
48
|
},
|
|
49
|
+
signal,
|
|
49
50
|
}), {
|
|
50
51
|
watch: [page],
|
|
51
52
|
},
|
|
@@ -70,6 +71,64 @@ const { data: user } = useAsyncData(
|
|
|
70
71
|
</script>
|
|
71
72
|
```
|
|
72
73
|
|
|
74
|
+
### Make your `handler` abortable
|
|
75
|
+
|
|
76
|
+
You can make your `handler` function abortable by using the `signal` provided in the second argument. This is useful for cancelling requests when they are no longer needed, such as when a user navigates away from a page. `$fetch` natively supports abort signals.
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
const { data, error } = await useAsyncData(
|
|
80
|
+
'users',
|
|
81
|
+
(_nuxtApp, { signal }) => $fetch('/api/users', { signal }),
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
refresh() // will actually cancel the $fetch request (if dedupe: cancel)
|
|
85
|
+
refresh() // will actually cancel the $fetch request (if dedupe: cancel)
|
|
86
|
+
refresh()
|
|
87
|
+
|
|
88
|
+
clear() // will cancel the latest pending handler
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
You can also pass an `AbortSignal` to the `refresh`/`execute` function to cancel individual requests manually.
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
const { refresh } = await useAsyncData(
|
|
95
|
+
'users',
|
|
96
|
+
(_nuxtApp, { signal }) => $fetch('/api/users', { signal }),
|
|
97
|
+
)
|
|
98
|
+
let abortController: AbortController | undefined
|
|
99
|
+
|
|
100
|
+
function handleUserAction () {
|
|
101
|
+
abortController = new AbortController()
|
|
102
|
+
refresh({ signal: abortController.signal })
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function handleCancel () {
|
|
106
|
+
abortController?.abort() // aborts the ongoing refresh request
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
If your `handler` function does not support abort signals, you can implement your own abort logic using the `signal` provided.
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
const { data, error } = await useAsyncData(
|
|
114
|
+
'users',
|
|
115
|
+
(_nuxtApp, { signal }) => {
|
|
116
|
+
return new Promise((resolve, reject) => {
|
|
117
|
+
signal?.addEventListener('abort', () => {
|
|
118
|
+
reject(new Error('Request aborted'))
|
|
119
|
+
})
|
|
120
|
+
return Promise.resolve(callback.call(this, yourHandler)).then(resolve, reject)
|
|
121
|
+
})
|
|
122
|
+
},
|
|
123
|
+
)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
The handler signal will be aborted when:
|
|
127
|
+
|
|
128
|
+
- A new request is made with `dedupe: 'cancel'`
|
|
129
|
+
- The `clear` function is called
|
|
130
|
+
- The `options.timeout` duration is exceeded
|
|
131
|
+
|
|
73
132
|
::warning
|
|
74
133
|
[`useAsyncData`](/docs/4.x/api/composables/use-async-data) is a reserved function name transformed by the compiler, so you should not name your own function [`useAsyncData`](/docs/4.x/api/composables/use-async-data).
|
|
75
134
|
::
|
|
@@ -116,7 +175,7 @@ You can use `useLazyAsyncData` to have the same behavior as `lazy: true` with `u
|
|
|
116
175
|
|
|
117
176
|
### Shared State and Option Consistency
|
|
118
177
|
|
|
119
|
-
When using the same key for multiple `useAsyncData` calls, they will share the same `data`, `error` and `
|
|
178
|
+
When using the same key for multiple `useAsyncData` calls, they will share the same `data`, `error`, `status` and `pending` refs. This ensures consistency across components but requires option consistency.
|
|
120
179
|
|
|
121
180
|
The following options **must be consistent** across all calls with the same key:
|
|
122
181
|
- `handler` function
|
|
@@ -135,12 +194,12 @@ The following options **can differ** without triggering warnings:
|
|
|
135
194
|
|
|
136
195
|
```ts
|
|
137
196
|
// ❌ This will trigger a development warning
|
|
138
|
-
const { data: users1 } = useAsyncData('users', () => $fetch('/api/users'), { deep: false })
|
|
139
|
-
const { data: users2 } = useAsyncData('users', () => $fetch('/api/users'), { deep: true })
|
|
197
|
+
const { data: users1 } = useAsyncData('users', (_nuxtApp, { signal }) => $fetch('/api/users', { signal }), { deep: false })
|
|
198
|
+
const { data: users2 } = useAsyncData('users', (_nuxtApp, { signal }) => $fetch('/api/users', { signal }), { deep: true })
|
|
140
199
|
|
|
141
200
|
// ✅ This is allowed
|
|
142
|
-
const { data: users1 } = useAsyncData('users', () => $fetch('/api/users'), { immediate: true })
|
|
143
|
-
const { data: users2 } = useAsyncData('users', () => $fetch('/api/users'), { immediate: false })
|
|
201
|
+
const { data: users1 } = useAsyncData('users', (_nuxtApp, { signal }) => $fetch('/api/users', { signal }), { immediate: true })
|
|
202
|
+
const { data: users2 } = useAsyncData('users', (_nuxtApp, { signal }) => $fetch('/api/users', { signal }), { immediate: false })
|
|
144
203
|
```
|
|
145
204
|
|
|
146
205
|
::tip
|
|
@@ -159,6 +218,7 @@ Keyed state created using `useAsyncData` can be retrieved across your Nuxt appli
|
|
|
159
218
|
- `pending`: the request is in progress
|
|
160
219
|
- `success`: the request has completed successfully
|
|
161
220
|
- `error`: the request has failed
|
|
221
|
+
- `pending`: a `Ref<boolean>` that is `true` while the request is in progress (that is, while `status.value === 'pending'`).
|
|
162
222
|
- `clear`: a function that can be used to set `data` to `undefined` (or the value of `options.default()` if provided), set `error` to `undefined`, set `status` to `idle`, and mark any currently pending requests as cancelled.
|
|
163
223
|
|
|
164
224
|
By default, Nuxt waits until a `refresh` is finished before it can be executed again.
|
|
@@ -170,13 +230,15 @@ If you have not fetched data on the server (for example, with `server: false`),
|
|
|
170
230
|
## Type
|
|
171
231
|
|
|
172
232
|
```ts [Signature]
|
|
233
|
+
export type AsyncDataHandler<ResT> = (nuxtApp: NuxtApp, options: { signal: AbortSignal }) => Promise<ResT>
|
|
234
|
+
|
|
173
235
|
export function useAsyncData<DataT, DataE> (
|
|
174
|
-
handler:
|
|
236
|
+
handler: AsyncDataHandler<DataT>,
|
|
175
237
|
options?: AsyncDataOptions<DataT>
|
|
176
238
|
): AsyncData<DataT, DataE>
|
|
177
239
|
export function useAsyncData<DataT, DataE> (
|
|
178
240
|
key: MaybeRefOrGetter<string>,
|
|
179
|
-
handler:
|
|
241
|
+
handler: AsyncDataHandler<DataT>,
|
|
180
242
|
options?: AsyncDataOptions<DataT>
|
|
181
243
|
): Promise<AsyncData<DataT, DataE>>
|
|
182
244
|
|
|
@@ -206,6 +268,7 @@ type AsyncData<DataT, ErrorT> = {
|
|
|
206
268
|
clear: () => void
|
|
207
269
|
error: Ref<ErrorT | undefined>
|
|
208
270
|
status: Ref<AsyncDataRequestStatus>
|
|
271
|
+
pending: Ref<boolean>
|
|
209
272
|
}
|
|
210
273
|
|
|
211
274
|
interface AsyncDataExecuteOptions {
|
|
@@ -61,14 +61,14 @@ Most of the options will be directly passed to the [cookie](https://github.com/j
|
|
|
61
61
|
| `default` | `() => T \| Ref<T>` | `undefined` | Function returning the default value if the cookie does not exist. The function can also return a `Ref`. |
|
|
62
62
|
| `watch` | `boolean \| 'shallow'` | `true` | Whether to watch for changes and update the cookie. `true` for deep watch, `'shallow'` for shallow watch, i.e. data changes for only top level properties, `false` to disable. <br/> **Note:** Refresh `useCookie` values manually when a cookie has changed with [`refreshCookie`](/docs/4.x/api/utils/refresh-cookie). |
|
|
63
63
|
| `readonly` | `boolean` | `false` | If `true`, disables writing to the cookie. |
|
|
64
|
-
| `maxAge` | `number` | `undefined` | Max age in seconds for the cookie, i.e. the value for the [`Max-Age` `Set-Cookie` attribute](https://
|
|
65
|
-
| `expires` | `Date` | `undefined` | Expiration date for the cookie. By default, no expiration is set. Most clients will consider this a "non-persistent cookie" and will delete it on a condition like exiting a web browser application. <br/> **Note:** The [cookie storage model specification](https://
|
|
64
|
+
| `maxAge` | `number` | `undefined` | Max age in seconds for the cookie, i.e. the value for the [`Max-Age` `Set-Cookie` attribute](https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.2). The given number will be converted to an integer by rounding down. By default, no maximum age is set. |
|
|
65
|
+
| `expires` | `Date` | `undefined` | Expiration date for the cookie. By default, no expiration is set. Most clients will consider this a "non-persistent cookie" and will delete it on a condition like exiting a web browser application. <br/> **Note:** The [cookie storage model specification](https://datatracker.ietf.org/doc/html/rfc6265#section-5.3) states that if both `expires` and `maxAge` is set, then `maxAge` takes precedence, but not all clients may obey this, so if both are set, they should point to the same date and time! <br/>If neither of `expires` and `maxAge` is set, the cookie will be session-only and removed when the user closes their browser. |
|
|
66
66
|
| `httpOnly` | `boolean` | `false` | Sets the HttpOnly attribute. <br/> **Note:** Be careful when setting this to `true`, as compliant clients will not allow client-side JavaScript to see the cookie in `document.cookie`. |
|
|
67
|
-
| `secure` | `boolean` | `false` | Sets the [`Secure` `Set-Cookie` attribute](https://
|
|
67
|
+
| `secure` | `boolean` | `false` | Sets the [`Secure` `Set-Cookie` attribute](https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.5). <br/>**Note:** Be careful when setting this to `true`, as compliant clients will not send the cookie back to the server in the future if the browser does not have an HTTPS connection. This can lead to hydration errors. |
|
|
68
68
|
| `partitioned` | `boolean` | `false` | Sets the [`Partitioned` `Set-Cookie` attribute](https://datatracker.ietf.org/doc/html/draft-cutler-httpbis-partitioned-cookies#section-2.1). <br/>**Note:** This is an attribute that has not yet been fully standardized, and may change in the future. <br/>This also means many clients may ignore this attribute until they understand it.<br/>More information can be found in the [proposal](https://github.com/privacycg/CHIPS). |
|
|
69
|
-
| `domain` | `string` | `undefined` | Sets the [`Domain` `Set-Cookie` attribute](https://
|
|
70
|
-
| `path` | `string` | `'/'` | Sets the [`Path` `Set-Cookie` attribute](https://
|
|
71
|
-
| `sameSite` | `boolean \| string` | `undefined` | Sets the [`SameSite` `Set-Cookie` attribute](https://
|
|
69
|
+
| `domain` | `string` | `undefined` | Sets the [`Domain` `Set-Cookie` attribute](https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.3). By default, no domain is set, and most clients will consider applying the cookie only to the current domain. |
|
|
70
|
+
| `path` | `string` | `'/'` | Sets the [`Path` `Set-Cookie` attribute](https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.4). By default, the path is considered the ["default path"](https://datatracker.ietf.org/doc/html/rfc6265#section-5.1.4). |
|
|
71
|
+
| `sameSite` | `boolean \| string` | `undefined` | Sets the [`SameSite` `Set-Cookie` attribute](https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7). <br/>- `true` will set the `SameSite` attribute to `Strict` for strict same-site enforcement.<br/>- `false` will not set the `SameSite` attribute.<br/>- `'lax'` will set the `SameSite` attribute to `Lax` for lax same-site enforcement.<br/>- `'none'` will set the `SameSite` attribute to `None` for an explicit cross-site cookie.<br/>- `'strict'` will set the `SameSite` attribute to `Strict` for strict same-site enforcement. |
|
|
72
72
|
|
|
73
73
|
## Return Values
|
|
74
74
|
|
|
@@ -100,7 +100,7 @@ If you encounter the `data` variable destructured from a `useFetch` returns a st
|
|
|
100
100
|
|
|
101
101
|
### Reactive Fetch Options
|
|
102
102
|
|
|
103
|
-
Fetch options can be provided as reactive, supporting `computed`, `ref` and [computed getters](https://vuejs.org/guide/essentials/computed
|
|
103
|
+
Fetch options can be provided as reactive, supporting `computed`, `ref` and [computed getters](https://vuejs.org/guide/essentials/computed). When a reactive fetch option is updated it will trigger a refetch using the updated resolved reactive value.
|
|
104
104
|
|
|
105
105
|
```ts
|
|
106
106
|
const searchQuery = ref('initial')
|
|
@@ -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/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/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.
|
|
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/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/guide/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
|
|
|
@@ -80,12 +80,12 @@ await nuxtApp.callHook('my-plugin:init')
|
|
|
80
80
|
|
|
81
81
|
### `vueApp`
|
|
82
82
|
|
|
83
|
-
`vueApp` is the global Vue.js [application instance](https://vuejs.org/api/application
|
|
83
|
+
`vueApp` is the global Vue.js [application instance](https://vuejs.org/api/application#application-api) that you can access through `nuxtApp`.
|
|
84
84
|
|
|
85
85
|
Some useful methods:
|
|
86
|
-
- [`component()`](https://vuejs.org/api/application
|
|
87
|
-
- [`directive()`](https://vuejs.org/api/application
|
|
88
|
-
- [`use()`](https://vuejs.org/api/application
|
|
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).
|
|
89
89
|
|
|
90
90
|
:read-more{icon="i-simple-icons-vuedotjs" to="https://vuejs.org/api/application.html#application-api"}
|
|
91
91
|
|
|
@@ -108,7 +108,7 @@ Nuxt exposes the following properties through `ssrContext`:
|
|
|
108
108
|
::code-group
|
|
109
109
|
```vue [app/app.vue]
|
|
110
110
|
<script setup lang="ts">
|
|
111
|
-
const { data } = await useAsyncData('count', () => $fetch('/api/count'))
|
|
111
|
+
const { data } = await useAsyncData('count', (_nuxtApp, { signal }) => $fetch('/api/count', { signal }))
|
|
112
112
|
</script>
|
|
113
113
|
```
|
|
114
114
|
```ts [server/api/count.ts]
|
|
@@ -67,7 +67,7 @@ Optimistic Updates is a technique where the user interface is updated immediatel
|
|
|
67
67
|
```vue [app/pages/todos.vue]
|
|
68
68
|
<script setup lang="ts">
|
|
69
69
|
// We can access same data later using 'todos' key
|
|
70
|
-
const { data } = await useAsyncData('todos', () => $fetch('/api/todos'))
|
|
70
|
+
const { data } = await useAsyncData('todos', (_nuxtApp, { signal }) => $fetch('/api/todos', { signal }))
|
|
71
71
|
</script>
|
|
72
72
|
```
|
|
73
73
|
|
|
@@ -33,7 +33,7 @@ const { data: forwarded } = await useAsyncData(() => requestFetch('/api/cookies'
|
|
|
33
33
|
|
|
34
34
|
// This will NOT forward anything
|
|
35
35
|
// Result: { cookies: {} }
|
|
36
|
-
const { data: notForwarded } = await useAsyncData(() => $fetch('/api/cookies'))
|
|
36
|
+
const { data: notForwarded } = await useAsyncData((_nuxtApp, { signal }) => $fetch('/api/cookies', { signal }))
|
|
37
37
|
</script>
|
|
38
38
|
```
|
|
39
39
|
|
|
@@ -84,4 +84,4 @@ Read more about accessing the route in the middleware section.
|
|
|
84
84
|
|
|
85
85
|
Browsers don't send [URL fragments](https://url.spec.whatwg.org/#concept-url-fragment) (for example `#foo`) when making requests. So using `route.fullPath` to affect the template can trigger hydration issues because this will include the fragment on client but not the server.
|
|
86
86
|
|
|
87
|
-
:read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/type-aliases/
|
|
87
|
+
:read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/type-aliases/routelocationnormalizedloaded"}
|
|
@@ -26,17 +26,17 @@ If you only need the router instance within your template, use `$router`:
|
|
|
26
26
|
|
|
27
27
|
If you have a `app/pages/` directory, `useRouter` is identical in behavior to the one provided by `vue-router`.
|
|
28
28
|
|
|
29
|
-
::read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/interfaces/
|
|
29
|
+
::read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/interfaces/router#Properties-currentRoute-" target="_blank"}
|
|
30
30
|
Read `vue-router` documentation about the `Router` interface.
|
|
31
31
|
::
|
|
32
32
|
|
|
33
33
|
## Basic Manipulation
|
|
34
34
|
|
|
35
|
-
- [`addRoute()`](https://router.vuejs.org/api/interfaces/
|
|
36
|
-
- [`removeRoute()`](https://router.vuejs.org/api/interfaces/
|
|
37
|
-
- [`getRoutes()`](https://router.vuejs.org/api/interfaces/
|
|
38
|
-
- [`hasRoute()`](https://router.vuejs.org/api/interfaces/
|
|
39
|
-
- [`resolve()`](https://router.vuejs.org/api/interfaces/
|
|
35
|
+
- [`addRoute()`](https://router.vuejs.org/api/interfaces/router#addRoute-): Add a new route to the router instance. `parentName` can be provided to add new route as the child of an existing route.
|
|
36
|
+
- [`removeRoute()`](https://router.vuejs.org/api/interfaces/router#removeRoute-): Remove an existing route by its name.
|
|
37
|
+
- [`getRoutes()`](https://router.vuejs.org/api/interfaces/router#getRoutes-): Get a full list of all the route records.
|
|
38
|
+
- [`hasRoute()`](https://router.vuejs.org/api/interfaces/router#hasRoute-): Checks if a route with a given name exists.
|
|
39
|
+
- [`resolve()`](https://router.vuejs.org/api/interfaces/router#resolve-): Returns the normalized version of a route location. Also includes an `href` property that includes any existing base.
|
|
40
40
|
|
|
41
41
|
```ts [Example]
|
|
42
42
|
const router = useRouter()
|
|
@@ -49,16 +49,16 @@ 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/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/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.
|
|
53
53
|
::
|
|
54
54
|
|
|
55
55
|
## Based on History API
|
|
56
56
|
|
|
57
|
-
- [`back()`](https://router.vuejs.org/api/interfaces/
|
|
58
|
-
- [`forward()`](https://router.vuejs.org/api/interfaces/
|
|
59
|
-
- [`go()`](https://router.vuejs.org/api/interfaces/
|
|
60
|
-
- [`push()`](https://router.vuejs.org/api/interfaces/
|
|
61
|
-
- [`replace()`](https://router.vuejs.org/api/interfaces/
|
|
57
|
+
- [`back()`](https://router.vuejs.org/api/interfaces/router#back-): Go back in history if possible, same as `router.go(-1)`.
|
|
58
|
+
- [`forward()`](https://router.vuejs.org/api/interfaces/router#forward-): Go forward in history if possible, same as `router.go(1)`.
|
|
59
|
+
- [`go()`](https://router.vuejs.org/api/interfaces/router#go-): Move forward or backward through the history without the hierarchical restrictions enforced in `router.back()` and `router.forward()`.
|
|
60
|
+
- [`push()`](https://router.vuejs.org/api/interfaces/router#push-): Programmatically navigate to a new URL by pushing an entry in the history stack. **It is recommended to use [`navigateTo`](/docs/4.x/api/utils/navigate-to) instead.**
|
|
61
|
+
- [`replace()`](https://router.vuejs.org/api/interfaces/router#replace-): Programmatically navigate to a new URL by replacing the current entry in the routes history stack. **It is recommended to use [`navigateTo`](/docs/4.x/api/utils/navigate-to) instead.**
|
|
62
62
|
|
|
63
63
|
```ts [Example]
|
|
64
64
|
const router = useRouter()
|
|
@@ -84,10 +84,10 @@ However, Nuxt has a concept of **route middleware** that simplifies the implemen
|
|
|
84
84
|
|
|
85
85
|
## Promise and Error Handling
|
|
86
86
|
|
|
87
|
-
- [`isReady()`](https://router.vuejs.org/api/interfaces/
|
|
88
|
-
- [`onError`](https://router.vuejs.org/api/interfaces/
|
|
87
|
+
- [`isReady()`](https://router.vuejs.org/api/interfaces/router#isReady-): Returns a Promise that resolves when the router has completed the initial navigation.
|
|
88
|
+
- [`onError`](https://router.vuejs.org/api/interfaces/router#onError-): Adds an error handler that is called every time a non caught error happens during navigation.
|
|
89
89
|
|
|
90
|
-
:read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/interfaces/
|
|
90
|
+
:read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/interfaces/router#Methods-" title="Vue Router Docs" target="_blank"}
|
|
91
91
|
|
|
92
92
|
## Universal Router Instance
|
|
93
93
|
|
|
@@ -29,7 +29,7 @@ Because the data inside `useState` will be serialized to JSON, it is important t
|
|
|
29
29
|
|
|
30
30
|
## Using `shallowRef`
|
|
31
31
|
|
|
32
|
-
If you don't need your state to be deeply reactive, you can combine `useState` with [`shallowRef`](https://vuejs.org/api/reactivity-advanced
|
|
32
|
+
If you don't need your state to be deeply reactive, you can combine `useState` with [`shallowRef`](https://vuejs.org/api/reactivity-advanced#shallowref). This can improve performance when your state contains large objects and arrays.
|
|
33
33
|
|
|
34
34
|
```ts
|
|
35
35
|
const state = useState('my-shallow-state', () => shallowRef({ deep: 'not reactive' }))
|
|
@@ -22,7 +22,7 @@ export function abortNavigation (err?: Error | string): false
|
|
|
22
22
|
|
|
23
23
|
### `err`
|
|
24
24
|
|
|
25
|
-
- **Type**: [`Error`](https://developer.mozilla.org/
|
|
25
|
+
- **Type**: [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) | `string`
|
|
26
26
|
|
|
27
27
|
Optional error to be thrown by `abortNavigation`.
|
|
28
28
|
|
|
@@ -60,7 +60,7 @@ export default defineNuxtRouteMiddleware((to, from) => {
|
|
|
60
60
|
|
|
61
61
|
### `err` as an Error Object
|
|
62
62
|
|
|
63
|
-
You can pass the error as an [`Error`](https://developer.mozilla.org/
|
|
63
|
+
You can pass the error as an [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object, e.g. caught by the `catch`-block:
|
|
64
64
|
|
|
65
65
|
```ts [app/middleware/auth.ts]
|
|
66
66
|
export default defineNuxtRouteMiddleware((to, from) => {
|
|
@@ -42,7 +42,7 @@ Read more about the options for `hydrate-on-visible`.
|
|
|
42
42
|
::
|
|
43
43
|
|
|
44
44
|
::note
|
|
45
|
-
Under the hood, this uses Vue's built-in [`hydrateOnVisible` strategy](https://vuejs.org/guide/components/async
|
|
45
|
+
Under the hood, this uses Vue's built-in [`hydrateOnVisible` strategy](https://vuejs.org/guide/components/async#hydrate-on-visible).
|
|
46
46
|
::
|
|
47
47
|
|
|
48
48
|
### Idle Strategy
|
|
@@ -70,7 +70,7 @@ The `hydrateOnIdle` prop is optional. You can pass a positive number to specify
|
|
|
70
70
|
Idle strategy is for components that can be hydrated when the browser is idle.
|
|
71
71
|
|
|
72
72
|
::note
|
|
73
|
-
Under the hood, this uses Vue's built-in [`hydrateOnIdle` strategy](https://vuejs.org/guide/components/async
|
|
73
|
+
Under the hood, this uses Vue's built-in [`hydrateOnIdle` strategy](https://vuejs.org/guide/components/async#hydrate-on-idle).
|
|
74
74
|
::
|
|
75
75
|
|
|
76
76
|
### Interaction Strategy
|
|
@@ -99,7 +99,7 @@ const LazyHydrationMyComponent = defineLazyHydrationComponent(
|
|
|
99
99
|
The `hydrateOnInteraction` prop is optional. If you do not pass an event or a list of events, it defaults to hydrating on `pointerenter`, `click`, and `focus`.
|
|
100
100
|
|
|
101
101
|
::note
|
|
102
|
-
Under the hood, this uses Vue's built-in [`hydrateOnInteraction` strategy](https://vuejs.org/guide/components/async
|
|
102
|
+
Under the hood, this uses Vue's built-in [`hydrateOnInteraction` strategy](https://vuejs.org/guide/components/async#hydrate-on-interaction).
|
|
103
103
|
::
|
|
104
104
|
|
|
105
105
|
### Media Query Strategy
|
|
@@ -126,7 +126,7 @@ const LazyHydrationMyComponent = defineLazyHydrationComponent(
|
|
|
126
126
|
```
|
|
127
127
|
|
|
128
128
|
::note
|
|
129
|
-
Under the hood, this uses Vue's built-in [`hydrateOnMediaQuery` strategy](https://vuejs.org/guide/components/async
|
|
129
|
+
Under the hood, this uses Vue's built-in [`hydrateOnMediaQuery` strategy](https://vuejs.org/guide/components/async#hydrate-on-media-query).
|
|
130
130
|
::
|
|
131
131
|
|
|
132
132
|
### Time Strategy
|
|
@@ -9,7 +9,7 @@ links:
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
::note
|
|
12
|
-
`defineNuxtComponent()` is a helper function for defining type safe Vue components using options API similar to [`defineComponent()`](https://vuejs.org/api/general
|
|
12
|
+
`defineNuxtComponent()` is a helper function for defining type safe Vue components using options API similar to [`defineComponent()`](https://vuejs.org/api/general#definecomponent). `defineNuxtComponent()` wrapper also adds support for `asyncData` and `head` component options.
|
|
13
13
|
::
|
|
14
14
|
|
|
15
15
|
::note
|
|
@@ -42,7 +42,7 @@ 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
|
|
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.
|
|
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
48
|
| Property | Type | Required | Description |
|
|
@@ -28,7 +28,7 @@ interface RouteMiddleware {
|
|
|
28
28
|
|
|
29
29
|
A function that takes two Vue Router's route location objects as parameters: the next route `to` as the first, and the current route `from` as the second.
|
|
30
30
|
|
|
31
|
-
Learn more about available properties of `RouteLocationNormalized` in the **[Vue Router docs](https://router.vuejs.org/api/type-aliases/
|
|
31
|
+
Learn more about available properties of `RouteLocationNormalized` in the **[Vue Router docs](https://router.vuejs.org/api/type-aliases/routelocationnormalized)**.
|
|
32
32
|
|
|
33
33
|
## Examples
|
|
34
34
|
|
|
@@ -62,7 +62,7 @@ interface PageMeta {
|
|
|
62
62
|
|
|
63
63
|
- **Type**: `string`
|
|
64
64
|
|
|
65
|
-
You may define a [custom regular expression](/docs/4.x/api/
|
|
65
|
+
You may define a [custom regular expression](/docs/4.x/api/utils/define-page-meta#using-a-custom-regular-expression) if you have a more complex pattern than can be expressed with the file name.
|
|
66
66
|
|
|
67
67
|
**`props`**
|
|
68
68
|
|
|
@@ -78,9 +78,9 @@ interface PageMeta {
|
|
|
78
78
|
|
|
79
79
|
**`keepalive`**
|
|
80
80
|
|
|
81
|
-
- **Type**: `boolean` | [`KeepAliveProps`](https://vuejs.org/api/built-in-components
|
|
81
|
+
- **Type**: `boolean` | [`KeepAliveProps`](https://vuejs.org/api/built-in-components#keepalive)
|
|
82
82
|
|
|
83
|
-
Set to `true` when you want to preserve page state across route changes or use the [`KeepAliveProps`](https://vuejs.org/api/built-in-components
|
|
83
|
+
Set to `true` when you want to preserve page state across route changes or use the [`KeepAliveProps`](https://vuejs.org/api/built-in-components#keepalive) for a fine-grained control.
|
|
84
84
|
|
|
85
85
|
**`key`**
|
|
86
86
|
|
|
@@ -96,19 +96,19 @@ interface PageMeta {
|
|
|
96
96
|
|
|
97
97
|
**`layoutTransition`**
|
|
98
98
|
|
|
99
|
-
- **Type**: `boolean` | [`TransitionProps`](https://vuejs.org/api/built-in-components
|
|
99
|
+
- **Type**: `boolean` | [`TransitionProps`](https://vuejs.org/api/built-in-components#transition)
|
|
100
100
|
|
|
101
101
|
Set name of the transition to apply for current layout. You can also set this value to `false` to disable the layout transition.
|
|
102
102
|
|
|
103
103
|
**`middleware`**
|
|
104
104
|
|
|
105
|
-
- **Type**: `MiddlewareKey` | [`NavigationGuard`](https://router.vuejs.org/api/interfaces/
|
|
105
|
+
- **Type**: `MiddlewareKey` | [`NavigationGuard`](https://router.vuejs.org/api/interfaces/navigationguard) | `Array<MiddlewareKey | NavigationGuard>`
|
|
106
106
|
|
|
107
107
|
Define anonymous or named middleware directly within `definePageMeta`. Learn more about [route middleware](/docs/4.x/guide/directory-structure/app/middleware).
|
|
108
108
|
|
|
109
109
|
**`pageTransition`**
|
|
110
110
|
|
|
111
|
-
- **Type**: `boolean` | [`TransitionProps`](https://vuejs.org/api/built-in-components
|
|
111
|
+
- **Type**: `boolean` | [`TransitionProps`](https://vuejs.org/api/built-in-components#transition)
|
|
112
112
|
|
|
113
113
|
Set name of the transition to apply for current page. You can also set this value to `false` to disable the page transition.
|
|
114
114
|
|
|
@@ -122,7 +122,7 @@ interface PageMeta {
|
|
|
122
122
|
|
|
123
123
|
**`redirect`**
|
|
124
124
|
|
|
125
|
-
- **Type**: [`RouteRecordRedirectOption`](https://router.vuejs.org/guide/essentials/redirect-and-alias
|
|
125
|
+
- **Type**: [`RouteRecordRedirectOption`](https://router.vuejs.org/guide/essentials/redirect-and-alias)
|
|
126
126
|
|
|
127
127
|
Where to redirect if the route is directly matched. The redirection happens before any navigation guard and triggers a new navigation with the new target location.
|
|
128
128
|
|
|
@@ -215,7 +215,7 @@ definePageMeta({
|
|
|
215
215
|
</script>
|
|
216
216
|
```
|
|
217
217
|
|
|
218
|
-
For more examples see [Vue Router's Matching Syntax](https://router.vuejs.org/guide/essentials/route-matching-syntax
|
|
218
|
+
For more examples see [Vue Router's Matching Syntax](https://router.vuejs.org/guide/essentials/route-matching-syntax).
|
|
219
219
|
|
|
220
220
|
### Defining Layout
|
|
221
221
|
|
|
@@ -17,7 +17,7 @@ Make sure to always use `await` or `return` on result of `navigateTo` when calli
|
|
|
17
17
|
::
|
|
18
18
|
|
|
19
19
|
::note
|
|
20
|
-
`navigateTo` cannot be used within Nitro routes. To perform a server-side redirect in Nitro routes, use [`sendRedirect`](https://h3.dev/utils/response#
|
|
20
|
+
`navigateTo` cannot be used within Nitro routes. To perform a server-side redirect in Nitro routes, use [`sendRedirect`](https://h3.dev/utils/response#redirectlocation-status-statustext) instead.
|
|
21
21
|
::
|
|
22
22
|
|
|
23
23
|
### Within a Vue Component
|
|
@@ -148,7 +148,7 @@ type OpenWindowFeatures = {
|
|
|
148
148
|
|
|
149
149
|
### `to`
|
|
150
150
|
|
|
151
|
-
**Type**: [`RouteLocationRaw`](https://router.vuejs.org/api/interfaces/
|
|
151
|
+
**Type**: [`RouteLocationRaw`](https://router.vuejs.org/api/interfaces/routelocationoptions) | `undefined` | `null`
|
|
152
152
|
|
|
153
153
|
**Default**: `'/'`
|
|
154
154
|
|
|
@@ -186,9 +186,9 @@ An object accepting the following properties:
|
|
|
186
186
|
- **Type**: `number`
|
|
187
187
|
- **Default**: `302`
|
|
188
188
|
|
|
189
|
-
- `navigateTo` redirects to the given path and sets the redirect code to [`302 Found`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302) by default when the redirection takes place on the server side.
|
|
189
|
+
- `navigateTo` redirects to the given path and sets the redirect code to [`302 Found`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/302) by default when the redirection takes place on the server side.
|
|
190
190
|
|
|
191
|
-
This default behavior can be modified by providing different `redirectCode`. Commonly, [`301 Moved Permanently`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/301) can be used for permanent redirections.
|
|
191
|
+
This default behavior can be modified by providing different `redirectCode`. Commonly, [`301 Moved Permanently`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/301) can be used for permanent redirections.
|
|
192
192
|
|
|
193
193
|
- `external`
|
|
194
194
|
|
|
@@ -8,4 +8,4 @@ links:
|
|
|
8
8
|
size: xs
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
:read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/functions/
|
|
11
|
+
:read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/functions/onbeforerouteleave" title="Vue Router Docs" target="_blank"}
|