@nuxt/docs-nightly 4.1.3-29313386.edc02e27 → 4.1.3-29316215.910d159d
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/01.introduction.md +4 -4
- package/1.getting-started/02.installation.md +1 -1
- package/1.getting-started/03.configuration.md +25 -25
- package/1.getting-started/04.views.md +3 -3
- package/1.getting-started/05.assets.md +9 -3
- package/1.getting-started/06.styling.md +53 -43
- package/1.getting-started/07.routing.md +9 -9
- package/1.getting-started/08.seo-meta.md +50 -37
- package/1.getting-started/09.transitions.md +38 -33
- package/1.getting-started/10.data-fetching.md +61 -53
- package/1.getting-started/11.state-management.md +19 -12
- package/1.getting-started/12.error-handling.md +17 -15
- package/1.getting-started/13.server.md +8 -8
- package/1.getting-started/14.layers.md +19 -13
- package/1.getting-started/15.prerendering.md +28 -28
- package/1.getting-started/16.deployment.md +8 -8
- package/1.getting-started/17.testing.md +42 -42
- package/1.getting-started/18.upgrade.md +50 -68
- package/2.guide/0.index.md +5 -5
- package/2.guide/1.directory-structure/0.output.md +1 -1
- package/2.guide/1.directory-structure/1.app/1.assets.md +1 -1
- package/2.guide/1.directory-structure/1.app/1.components.md +40 -23
- package/2.guide/1.directory-structure/1.app/1.composables.md +9 -9
- package/2.guide/1.directory-structure/1.app/1.layouts.md +12 -8
- package/2.guide/1.directory-structure/1.app/1.middleware.md +23 -17
- package/2.guide/1.directory-structure/1.app/1.pages.md +25 -23
- package/2.guide/1.directory-structure/1.app/1.plugins.md +17 -17
- package/2.guide/1.directory-structure/1.app/1.utils.md +3 -3
- package/2.guide/1.directory-structure/1.app/3.app-config.md +7 -7
- package/2.guide/1.directory-structure/1.app/3.app.md +3 -3
- package/2.guide/1.directory-structure/1.app/3.error.md +4 -4
- package/2.guide/1.directory-structure/1.content.md +4 -1
- package/2.guide/1.directory-structure/1.modules.md +5 -5
- package/2.guide/1.directory-structure/1.public.md +1 -1
- package/2.guide/1.directory-structure/1.server.md +30 -30
- package/2.guide/1.directory-structure/1.shared.md +3 -3
- package/2.guide/1.directory-structure/2.env.md +3 -3
- package/2.guide/1.directory-structure/2.nuxtrc.md +1 -1
- package/2.guide/1.directory-structure/3.nuxt-config.md +1 -1
- package/2.guide/2.concepts/1.auto-imports.md +15 -15
- package/2.guide/2.concepts/10.nuxt-lifecycle.md +7 -7
- package/2.guide/2.concepts/2.vuejs-development.md +9 -9
- package/2.guide/2.concepts/3.rendering.md +17 -15
- package/2.guide/2.concepts/4.server-engine.md +1 -1
- package/2.guide/2.concepts/5.modules.md +3 -3
- package/2.guide/2.concepts/7.esm.md +16 -14
- package/2.guide/2.concepts/8.typescript.md +4 -4
- package/2.guide/3.going-further/1.events.md +3 -3
- package/2.guide/3.going-further/1.experimental-features.md +238 -77
- package/2.guide/3.going-further/1.features.md +44 -9
- package/2.guide/3.going-further/1.internals.md +15 -15
- package/2.guide/3.going-further/10.runtime-config.md +8 -8
- package/2.guide/3.going-further/11.nightly-release-channel.md +1 -1
- package/2.guide/3.going-further/2.hooks.md +11 -11
- package/2.guide/3.going-further/3.modules.md +83 -81
- package/2.guide/3.going-further/4.kit.md +5 -5
- package/2.guide/3.going-further/6.nuxt-app.md +4 -4
- package/2.guide/3.going-further/7.layers.md +51 -42
- package/2.guide/3.going-further/9.debugging.md +2 -2
- package/2.guide/4.recipes/1.custom-routing.md +19 -19
- package/2.guide/4.recipes/2.vite-plugin.md +3 -3
- package/2.guide/4.recipes/3.custom-usefetch.md +10 -10
- package/2.guide/4.recipes/4.sessions-and-authentication.md +34 -20
- package/2.guide/5.best-practices/performance.md +13 -13
- package/3.api/1.components/1.client-only.md +6 -3
- package/3.api/1.components/1.nuxt-client-fallback.md +10 -7
- package/3.api/1.components/11.teleports.md +5 -2
- package/3.api/1.components/12.nuxt-route-announcer.md +7 -7
- package/3.api/1.components/13.nuxt-time.md +44 -17
- package/3.api/1.components/2.nuxt-page.md +4 -4
- package/3.api/1.components/3.nuxt-layout.md +13 -8
- package/3.api/1.components/4.nuxt-link.md +40 -20
- package/3.api/1.components/5.nuxt-loading-indicator.md +1 -1
- package/3.api/1.components/6.nuxt-error-boundary.md +12 -10
- package/3.api/2.composables/on-prehydrate.md +2 -2
- package/3.api/2.composables/use-app-config.md +1 -1
- package/3.api/2.composables/use-async-data.md +14 -14
- package/3.api/2.composables/use-cookie.md +27 -19
- package/3.api/2.composables/use-error.md +2 -2
- package/3.api/2.composables/use-fetch.md +17 -17
- package/3.api/2.composables/use-head-safe.md +5 -5
- package/3.api/2.composables/use-head.md +3 -3
- package/3.api/2.composables/use-hydration.md +5 -5
- package/3.api/2.composables/use-lazy-async-data.md +2 -2
- package/3.api/2.composables/use-lazy-fetch.md +2 -2
- package/3.api/2.composables/use-loading-indicator.md +10 -10
- package/3.api/2.composables/use-nuxt-app.md +10 -10
- package/3.api/2.composables/use-nuxt-data.md +7 -7
- package/3.api/2.composables/use-preview-mode.md +12 -15
- package/3.api/2.composables/use-request-fetch.md +1 -1
- package/3.api/2.composables/use-request-headers.md +3 -3
- package/3.api/2.composables/use-response-header.md +7 -8
- package/3.api/2.composables/use-route-announcer.md +3 -3
- package/3.api/2.composables/use-router.md +6 -4
- package/3.api/2.composables/use-runtime-config.md +11 -11
- package/3.api/2.composables/use-runtime-hook.md +1 -1
- package/3.api/2.composables/use-seo-meta.md +3 -3
- package/3.api/2.composables/use-server-seo-meta.md +3 -3
- package/3.api/2.composables/use-state.md +4 -4
- package/3.api/3.utils/$fetch.md +6 -4
- package/3.api/3.utils/abort-navigation.md +2 -2
- package/3.api/3.utils/add-route-middleware.md +3 -3
- package/3.api/3.utils/call-once.md +5 -5
- package/3.api/3.utils/clear-error.md +2 -2
- package/3.api/3.utils/clear-nuxt-data.md +2 -2
- package/3.api/3.utils/clear-nuxt-state.md +2 -2
- package/3.api/3.utils/create-error.md +2 -2
- package/3.api/3.utils/define-lazy-hydration-component.md +13 -13
- package/3.api/3.utils/define-nuxt-component.md +5 -5
- package/3.api/3.utils/define-nuxt-plugin.md +12 -12
- package/3.api/3.utils/define-nuxt-route-middleware.md +2 -2
- package/3.api/3.utils/define-page-meta.md +16 -16
- package/3.api/3.utils/define-route-rules.md +5 -5
- package/3.api/3.utils/navigate-to.md +10 -10
- package/3.api/3.utils/preload-components.md +1 -1
- package/3.api/3.utils/preload-route-components.md +2 -2
- package/3.api/3.utils/prerender-routes.md +2 -2
- package/3.api/3.utils/refresh-cookie.md +4 -4
- package/3.api/3.utils/refresh-nuxt-data.md +10 -5
- package/3.api/3.utils/reload-nuxt-app.md +3 -3
- package/3.api/3.utils/set-response-status.md +2 -2
- package/3.api/3.utils/show-error.md +3 -3
- package/3.api/3.utils/update-app-config.md +3 -2
- package/3.api/4.commands/generate.md +1 -1
- package/3.api/4.commands/prepare.md +4 -0
- package/3.api/4.commands/typecheck.md +1 -1
- package/3.api/5.kit/1.modules.md +36 -36
- package/3.api/5.kit/10.templates.md +8 -6
- package/3.api/5.kit/11.nitro.md +62 -62
- package/3.api/5.kit/12.resolving.md +2 -2
- package/3.api/5.kit/14.builder.md +1 -0
- package/3.api/5.kit/15.examples.md +2 -2
- package/3.api/5.kit/16.layers.md +26 -26
- package/3.api/5.kit/3.compatibility.md +12 -12
- package/3.api/5.kit/4.autoimports.md +12 -12
- package/3.api/5.kit/5.components.md +5 -5
- package/3.api/5.kit/6.context.md +3 -3
- package/3.api/5.kit/7.pages.md +4 -4
- package/3.api/5.kit/8.layout.md +1 -1
- package/3.api/5.kit/9.plugins.md +5 -4
- package/3.api/6.advanced/1.hooks.md +1 -1
- package/3.api/6.advanced/2.import-meta.md +3 -3
- package/3.api/6.nuxt-config.md +299 -864
- package/3.api/index.md +7 -7
- package/5.community/4.contribution.md +5 -5
- package/5.community/5.framework-contribution.md +1 -1
- package/6.bridge/1.overview.md +1 -1
- package/6.bridge/10.configuration.md +2 -1
- package/6.bridge/2.typescript.md +2 -2
- package/6.bridge/3.bridge-composition-api.md +4 -4
- package/6.bridge/4.plugins-and-middleware.md +5 -5
- package/6.bridge/5.nuxt3-compatible-api.md +12 -9
- package/6.bridge/6.meta.md +15 -14
- package/6.bridge/8.nitro.md +2 -2
- package/6.bridge/9.vite.md +3 -3
- package/7.migration/10.bundling.md +1 -1
- package/7.migration/11.server.md +3 -3
- package/7.migration/2.configuration.md +18 -16
- package/7.migration/20.module-authors.md +1 -1
- package/7.migration/4.meta.md +18 -15
- package/7.migration/5.plugins-and-middleware.md +8 -8
- package/7.migration/6.pages-and-layouts.md +20 -16
- package/7.migration/7.component-options.md +7 -7
- package/7.migration/8.runtime-config.md +4 -4
- package/package.json +1 -1
|
@@ -27,13 +27,13 @@ export default defineNuxtConfig({
|
|
|
27
27
|
},
|
|
28
28
|
link: [
|
|
29
29
|
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
|
|
30
|
-
]
|
|
31
|
-
}
|
|
32
|
-
}
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
33
|
})
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
You can also provide any of the keys listed below in [Types](/docs/getting-started/seo-meta#types).
|
|
36
|
+
You can also provide any of the keys listed below in [Types](/docs/4.x/getting-started/seo-meta#types).
|
|
37
37
|
|
|
38
38
|
### Defaults Tags
|
|
39
39
|
|
|
@@ -51,8 +51,8 @@ export default defineNuxtConfig({
|
|
|
51
51
|
// update Nuxt defaults
|
|
52
52
|
charset: 'utf-16',
|
|
53
53
|
viewport: 'width=device-width, initial-scale=1, maximum-scale=1',
|
|
54
|
-
}
|
|
55
|
-
}
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
56
|
})
|
|
57
57
|
```
|
|
58
58
|
|
|
@@ -65,12 +65,12 @@ The [`useHead`](/docs/4.x/api/composables/use-head) composable function supports
|
|
|
65
65
|
useHead({
|
|
66
66
|
title: 'My App',
|
|
67
67
|
meta: [
|
|
68
|
-
{ name: 'description', content: 'My amazing site.' }
|
|
68
|
+
{ name: 'description', content: 'My amazing site.' },
|
|
69
69
|
],
|
|
70
70
|
bodyAttrs: {
|
|
71
|
-
class: 'test'
|
|
71
|
+
class: 'test',
|
|
72
72
|
},
|
|
73
|
-
script: [
|
|
73
|
+
script: [{ innerHTML: 'console.log(\'Hello world\')' }],
|
|
74
74
|
})
|
|
75
75
|
</script>
|
|
76
76
|
```
|
|
@@ -96,7 +96,7 @@ useSeoMeta({
|
|
|
96
96
|
</script>
|
|
97
97
|
```
|
|
98
98
|
|
|
99
|
-
:read-more{to="/docs/api/composables/use-seo-meta"}
|
|
99
|
+
:read-more{to="/docs/4.x/api/composables/use-seo-meta"}
|
|
100
100
|
|
|
101
101
|
## Components
|
|
102
102
|
|
|
@@ -118,9 +118,12 @@ const title = ref('Hello World')
|
|
|
118
118
|
<div>
|
|
119
119
|
<Head>
|
|
120
120
|
<Title>{{ title }}</Title>
|
|
121
|
-
<Meta
|
|
121
|
+
<Meta
|
|
122
|
+
name="description"
|
|
123
|
+
:content="title"
|
|
124
|
+
/>
|
|
122
125
|
<Style>
|
|
123
|
-
|
|
126
|
+
body { background-color: green; }
|
|
124
127
|
</Style>
|
|
125
128
|
</Head>
|
|
126
129
|
|
|
@@ -145,9 +148,9 @@ interface MetaObject {
|
|
|
145
148
|
meta?: Meta[]
|
|
146
149
|
style?: Style[]
|
|
147
150
|
script?: Script[]
|
|
148
|
-
noscript?: Noscript[]
|
|
149
|
-
htmlAttrs?: HtmlAttributes
|
|
150
|
-
bodyAttrs?: BodyAttributes
|
|
151
|
+
noscript?: Noscript[]
|
|
152
|
+
htmlAttrs?: HtmlAttributes
|
|
153
|
+
bodyAttrs?: BodyAttributes
|
|
151
154
|
}
|
|
152
155
|
```
|
|
153
156
|
|
|
@@ -167,7 +170,7 @@ Reactivity is supported on all properties, by providing a computed value, a gett
|
|
|
167
170
|
|
|
168
171
|
useHead({
|
|
169
172
|
meta: [
|
|
170
|
-
{ name: 'description', content: description }
|
|
173
|
+
{ name: 'description', content: description },
|
|
171
174
|
],
|
|
172
175
|
})
|
|
173
176
|
</script>
|
|
@@ -178,7 +181,7 @@ Reactivity is supported on all properties, by providing a computed value, a gett
|
|
|
178
181
|
const description = ref('My amazing site.')
|
|
179
182
|
|
|
180
183
|
useSeoMeta({
|
|
181
|
-
description
|
|
184
|
+
description,
|
|
182
185
|
})
|
|
183
186
|
</script>
|
|
184
187
|
```
|
|
@@ -190,7 +193,10 @@ Reactivity is supported on all properties, by providing a computed value, a gett
|
|
|
190
193
|
|
|
191
194
|
<template>
|
|
192
195
|
<div>
|
|
193
|
-
<Meta
|
|
196
|
+
<Meta
|
|
197
|
+
name="description"
|
|
198
|
+
:content="description"
|
|
199
|
+
/>
|
|
194
200
|
</div>
|
|
195
201
|
</template>
|
|
196
202
|
```
|
|
@@ -211,8 +217,8 @@ If you want to use a function (for full control), then this cannot be set in you
|
|
|
211
217
|
<script setup lang="ts">
|
|
212
218
|
useHead({
|
|
213
219
|
titleTemplate: (titleChunk) => {
|
|
214
|
-
return titleChunk ? `${titleChunk} - Site Title` : 'Site Title'
|
|
215
|
-
}
|
|
220
|
+
return titleChunk ? `${titleChunk} - Site Title` : 'Site Title'
|
|
221
|
+
},
|
|
216
222
|
})
|
|
217
223
|
</script>
|
|
218
224
|
```
|
|
@@ -231,12 +237,12 @@ You can use `templateParams` to provide additional placeholders in your `titleTe
|
|
|
231
237
|
<script setup lang="ts">
|
|
232
238
|
useHead({
|
|
233
239
|
titleTemplate: (titleChunk) => {
|
|
234
|
-
return titleChunk ? `${titleChunk} %separator %siteName` : '%siteName'
|
|
240
|
+
return titleChunk ? `${titleChunk} %separator %siteName` : '%siteName'
|
|
235
241
|
},
|
|
236
242
|
templateParams: {
|
|
237
243
|
siteName: 'Site Title',
|
|
238
|
-
separator: '-'
|
|
239
|
-
}
|
|
244
|
+
separator: '-',
|
|
245
|
+
},
|
|
240
246
|
})
|
|
241
247
|
</script>
|
|
242
248
|
```
|
|
@@ -256,9 +262,9 @@ useHead({
|
|
|
256
262
|
{
|
|
257
263
|
src: 'https://third-party-script.com',
|
|
258
264
|
// valid options are: 'head' | 'bodyClose' | 'bodyOpen'
|
|
259
|
-
tagPosition: 'bodyClose'
|
|
260
|
-
}
|
|
261
|
-
]
|
|
265
|
+
tagPosition: 'bodyClose',
|
|
266
|
+
},
|
|
267
|
+
],
|
|
262
268
|
})
|
|
263
269
|
</script>
|
|
264
270
|
```
|
|
@@ -274,7 +280,7 @@ For example, you can first set the current page title (this is extracted at buil
|
|
|
274
280
|
```vue twoslash [pages/some-page.vue]
|
|
275
281
|
<script setup lang="ts">
|
|
276
282
|
definePageMeta({
|
|
277
|
-
title: 'Some Page'
|
|
283
|
+
title: 'Some Page',
|
|
278
284
|
})
|
|
279
285
|
</script>
|
|
280
286
|
```
|
|
@@ -286,14 +292,14 @@ And then in your layout file, you might use the route's metadata you have previo
|
|
|
286
292
|
const route = useRoute()
|
|
287
293
|
|
|
288
294
|
useHead({
|
|
289
|
-
meta: [{ property: 'og:title', content: `App Name - ${route.meta.title}` }]
|
|
295
|
+
meta: [{ property: 'og:title', content: `App Name - ${route.meta.title}` }],
|
|
290
296
|
})
|
|
291
297
|
</script>
|
|
292
298
|
```
|
|
293
299
|
|
|
294
|
-
:link-example{to="/docs/examples/features/meta-tags"}
|
|
300
|
+
:link-example{to="/docs/4.x/examples/features/meta-tags"}
|
|
295
301
|
|
|
296
|
-
:read-more{to="/docs/guide/directory-structure/app/pages/#page-metadata"}
|
|
302
|
+
:read-more{to="/docs/4.x/guide/directory-structure/app/pages/#page-metadata"}
|
|
297
303
|
|
|
298
304
|
### Dynamic Title
|
|
299
305
|
|
|
@@ -317,7 +323,7 @@ useHead({
|
|
|
317
323
|
return productCategory
|
|
318
324
|
? `${productCategory} - Site Title`
|
|
319
325
|
: 'Site Title'
|
|
320
|
-
}
|
|
326
|
+
},
|
|
321
327
|
})
|
|
322
328
|
</script>
|
|
323
329
|
```
|
|
@@ -336,14 +342,14 @@ The example below shows how you might enable Google Fonts using either the `link
|
|
|
336
342
|
link: [
|
|
337
343
|
{
|
|
338
344
|
rel: 'preconnect',
|
|
339
|
-
href: 'https://fonts.googleapis.com'
|
|
345
|
+
href: 'https://fonts.googleapis.com',
|
|
340
346
|
},
|
|
341
347
|
{
|
|
342
348
|
rel: 'stylesheet',
|
|
343
349
|
href: 'https://fonts.googleapis.com/css2?family=Roboto&display=swap',
|
|
344
|
-
crossorigin: ''
|
|
345
|
-
}
|
|
346
|
-
]
|
|
350
|
+
crossorigin: '',
|
|
351
|
+
},
|
|
352
|
+
],
|
|
347
353
|
})
|
|
348
354
|
</script>
|
|
349
355
|
```
|
|
@@ -351,8 +357,15 @@ The example below shows how you might enable Google Fonts using either the `link
|
|
|
351
357
|
```vue [app/Components]
|
|
352
358
|
<template>
|
|
353
359
|
<div>
|
|
354
|
-
<Link
|
|
355
|
-
|
|
360
|
+
<Link
|
|
361
|
+
rel="preconnect"
|
|
362
|
+
href="https://fonts.googleapis.com"
|
|
363
|
+
/>
|
|
364
|
+
<Link
|
|
365
|
+
rel="stylesheet"
|
|
366
|
+
href="https://fonts.googleapis.com/css2?family=Roboto&display=swap"
|
|
367
|
+
crossorigin=""
|
|
368
|
+
/>
|
|
356
369
|
</div>
|
|
357
370
|
</template>
|
|
358
371
|
```
|
|
@@ -15,8 +15,8 @@ You can enable page transitions to apply an automatic transition for all your [p
|
|
|
15
15
|
```ts twoslash [nuxt.config.ts]
|
|
16
16
|
export default defineNuxtConfig({
|
|
17
17
|
app: {
|
|
18
|
-
pageTransition: { name: 'page', mode: 'out-in' }
|
|
19
|
-
}
|
|
18
|
+
pageTransition: { name: 'page', mode: 'out-in' },
|
|
19
|
+
},
|
|
20
20
|
})
|
|
21
21
|
```
|
|
22
22
|
|
|
@@ -80,8 +80,8 @@ To set a different transition for a page, set the `pageTransition` key in [`defi
|
|
|
80
80
|
<script setup lang="ts">
|
|
81
81
|
definePageMeta({
|
|
82
82
|
pageTransition: {
|
|
83
|
-
name: 'rotate'
|
|
84
|
-
}
|
|
83
|
+
name: 'rotate',
|
|
84
|
+
},
|
|
85
85
|
})
|
|
86
86
|
</script>
|
|
87
87
|
```
|
|
@@ -120,8 +120,8 @@ You can enable layout transitions to apply an automatic transition for all your
|
|
|
120
120
|
```ts twoslash [nuxt.config.ts]
|
|
121
121
|
export default defineNuxtConfig({
|
|
122
122
|
app: {
|
|
123
|
-
layoutTransition: { name: 'layout', mode: 'out-in' }
|
|
124
|
-
}
|
|
123
|
+
layoutTransition: { name: 'layout', mode: 'out-in' },
|
|
124
|
+
},
|
|
125
125
|
})
|
|
126
126
|
```
|
|
127
127
|
|
|
@@ -192,7 +192,7 @@ div {
|
|
|
192
192
|
```vue [app/pages/about.vue]
|
|
193
193
|
<script setup lang="ts">
|
|
194
194
|
definePageMeta({
|
|
195
|
-
layout: 'orange'
|
|
195
|
+
layout: 'orange',
|
|
196
196
|
})
|
|
197
197
|
</script>
|
|
198
198
|
|
|
@@ -219,8 +219,8 @@ Similar to `pageTransition`, you can apply a custom `layoutTransition` to the pa
|
|
|
219
219
|
definePageMeta({
|
|
220
220
|
layout: 'orange',
|
|
221
221
|
layoutTransition: {
|
|
222
|
-
name: 'slide-in'
|
|
223
|
-
}
|
|
222
|
+
name: 'slide-in',
|
|
223
|
+
},
|
|
224
224
|
})
|
|
225
225
|
</script>
|
|
226
226
|
```
|
|
@@ -236,13 +236,13 @@ export default defineNuxtConfig({
|
|
|
236
236
|
app: {
|
|
237
237
|
pageTransition: {
|
|
238
238
|
name: 'fade',
|
|
239
|
-
mode: 'out-in' // default
|
|
239
|
+
mode: 'out-in', // default
|
|
240
240
|
},
|
|
241
241
|
layoutTransition: {
|
|
242
242
|
name: 'slide',
|
|
243
|
-
mode: 'out-in' // default
|
|
244
|
-
}
|
|
245
|
-
}
|
|
243
|
+
mode: 'out-in', // default
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
246
|
})
|
|
247
247
|
```
|
|
248
248
|
|
|
@@ -257,8 +257,8 @@ To override the global transition property, use the `definePageMeta` to define p
|
|
|
257
257
|
definePageMeta({
|
|
258
258
|
pageTransition: {
|
|
259
259
|
name: 'bounce',
|
|
260
|
-
mode: 'out-in' // default
|
|
261
|
-
}
|
|
260
|
+
mode: 'out-in', // default
|
|
261
|
+
},
|
|
262
262
|
})
|
|
263
263
|
</script>
|
|
264
264
|
```
|
|
@@ -271,7 +271,7 @@ definePageMeta({
|
|
|
271
271
|
<script setup lang="ts">
|
|
272
272
|
definePageMeta({
|
|
273
273
|
pageTransition: false,
|
|
274
|
-
layoutTransition: false
|
|
274
|
+
layoutTransition: false,
|
|
275
275
|
})
|
|
276
276
|
</script>
|
|
277
277
|
```
|
|
@@ -282,8 +282,8 @@ Or globally in the `nuxt.config`:
|
|
|
282
282
|
export default defineNuxtConfig({
|
|
283
283
|
app: {
|
|
284
284
|
pageTransition: false,
|
|
285
|
-
layoutTransition: false
|
|
286
|
-
}
|
|
285
|
+
layoutTransition: false,
|
|
286
|
+
},
|
|
287
287
|
})
|
|
288
288
|
```
|
|
289
289
|
|
|
@@ -303,8 +303,8 @@ definePageMeta({
|
|
|
303
303
|
console.log('Before enter...')
|
|
304
304
|
},
|
|
305
305
|
onEnter: (el, done) => {},
|
|
306
|
-
onAfterEnter: (el) => {}
|
|
307
|
-
}
|
|
306
|
+
onAfterEnter: (el) => {},
|
|
307
|
+
},
|
|
308
308
|
})
|
|
309
309
|
</script>
|
|
310
310
|
```
|
|
@@ -324,12 +324,13 @@ To apply dynamic transitions using conditional logic, you can leverage inline [m
|
|
|
324
324
|
definePageMeta({
|
|
325
325
|
pageTransition: {
|
|
326
326
|
name: 'slide-right',
|
|
327
|
-
mode: 'out-in'
|
|
327
|
+
mode: 'out-in',
|
|
328
328
|
},
|
|
329
329
|
middleware (to, from) {
|
|
330
|
-
if (to.meta.pageTransition && typeof to.meta.pageTransition !== 'boolean')
|
|
330
|
+
if (to.meta.pageTransition && typeof to.meta.pageTransition !== 'boolean') {
|
|
331
331
|
to.meta.pageTransition.name = +to.params.id! > +from.params.id! ? 'slide-left' : 'slide-right'
|
|
332
|
-
|
|
332
|
+
}
|
|
333
|
+
},
|
|
333
334
|
})
|
|
334
335
|
</script>
|
|
335
336
|
|
|
@@ -398,10 +399,12 @@ When `<NuxtPage />` is used in `app.vue`, transitions can be configured with the
|
|
|
398
399
|
<template>
|
|
399
400
|
<div>
|
|
400
401
|
<NuxtLayout>
|
|
401
|
-
<NuxtPage
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
402
|
+
<NuxtPage
|
|
403
|
+
:transition="{
|
|
404
|
+
name: 'bounce',
|
|
405
|
+
mode: 'out-in',
|
|
406
|
+
}"
|
|
407
|
+
/>
|
|
405
408
|
</NuxtLayout>
|
|
406
409
|
</div>
|
|
407
410
|
</template>
|
|
@@ -422,8 +425,8 @@ The Nuxt integration can be enabled with the `experimental.viewTransition` optio
|
|
|
422
425
|
```ts twoslash [nuxt.config.ts]
|
|
423
426
|
export default defineNuxtConfig({
|
|
424
427
|
experimental: {
|
|
425
|
-
viewTransition: true
|
|
426
|
-
}
|
|
428
|
+
viewTransition: true,
|
|
429
|
+
},
|
|
427
430
|
})
|
|
428
431
|
```
|
|
429
432
|
|
|
@@ -437,7 +440,7 @@ By default, view transitions are enabled for all [pages](/docs/4.x/guide/directo
|
|
|
437
440
|
export default defineNuxtConfig({
|
|
438
441
|
app: {
|
|
439
442
|
// Disable view transitions globally, and opt-in on a per page basis
|
|
440
|
-
viewTransition: false
|
|
443
|
+
viewTransition: false,
|
|
441
444
|
},
|
|
442
445
|
})
|
|
443
446
|
```
|
|
@@ -447,7 +450,7 @@ It is possible to override the default `viewTransition` value for a page by sett
|
|
|
447
450
|
```vue twoslash [pages/about.vue]
|
|
448
451
|
<script setup lang="ts">
|
|
449
452
|
definePageMeta({
|
|
450
|
-
viewTransition: false
|
|
453
|
+
viewTransition: false,
|
|
451
454
|
})
|
|
452
455
|
</script>
|
|
453
456
|
```
|
|
@@ -459,8 +462,10 @@ Overriding view transitions on a per-page basis will only have an effect if you
|
|
|
459
462
|
If you are also using Vue transitions like `pageTransition` and `layoutTransition` (see above) to achieve the same result as the new View Transitions API, then you may wish to _disable_ Vue transitions if the user's browser supports the newer, native web API. You can do this by creating `~/middleware/disable-vue-transitions.global.ts` with the following contents:
|
|
460
463
|
|
|
461
464
|
```ts
|
|
462
|
-
export default defineNuxtRouteMiddleware(to => {
|
|
463
|
-
if (import.meta.server || !document.startViewTransition) {
|
|
465
|
+
export default defineNuxtRouteMiddleware((to) => {
|
|
466
|
+
if (import.meta.server || !document.startViewTransition) {
|
|
467
|
+
return
|
|
468
|
+
}
|
|
464
469
|
|
|
465
470
|
// Disable built-in Vue transitions
|
|
466
471
|
to.meta.pageTransition = false
|