@nuxt/docs 3.20.2 → 3.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/1.getting-started/01.introduction.md +4 -4
- package/1.getting-started/02.installation.md +4 -7
- package/1.getting-started/03.configuration.md +29 -29
- package/1.getting-started/04.views.md +6 -4
- package/1.getting-started/05.assets.md +2 -2
- package/1.getting-started/06.styling.md +22 -16
- package/1.getting-started/07.routing.md +6 -6
- package/1.getting-started/08.seo-meta.md +8 -4
- package/1.getting-started/09.transitions.md +6 -6
- package/1.getting-started/10.data-fetching.md +18 -18
- package/1.getting-started/11.state-management.md +5 -5
- package/1.getting-started/12.error-handling.md +25 -19
- package/1.getting-started/13.server.md +9 -9
- package/1.getting-started/14.layers.md +49 -15
- package/1.getting-started/15.prerendering.md +10 -4
- package/1.getting-started/16.deployment.md +2 -1
- package/1.getting-started/17.testing.md +17 -7
- package/1.getting-started/18.upgrade.md +111 -60
- package/2.directory-structure/0.output.md +1 -1
- package/2.directory-structure/1.assets.md +1 -1
- package/2.directory-structure/1.components.md +12 -8
- package/2.directory-structure/1.composables.md +2 -2
- package/2.directory-structure/1.content.md +1 -1
- package/2.directory-structure/1.layers.md +87 -0
- package/2.directory-structure/1.layouts.md +35 -3
- package/2.directory-structure/1.middleware.md +7 -7
- package/2.directory-structure/1.modules.md +8 -2
- package/2.directory-structure/1.node_modules.md +1 -1
- package/2.directory-structure/1.pages.md +39 -18
- package/2.directory-structure/1.plugins.md +4 -1
- package/2.directory-structure/1.public.md +1 -1
- package/2.directory-structure/1.server.md +28 -8
- package/2.directory-structure/1.shared.md +3 -3
- package/2.directory-structure/1.utils.md +2 -2
- package/2.directory-structure/2.env.md +3 -3
- package/2.directory-structure/2.nuxtignore.md +1 -0
- package/2.directory-structure/2.nuxtrc.md +5 -2
- package/2.directory-structure/3.app-config.md +2 -2
- package/2.directory-structure/3.app.md +3 -3
- package/2.directory-structure/3.error.md +9 -5
- package/2.directory-structure/3.nuxt-config.md +1 -1
- package/2.directory-structure/3.package.md +1 -1
- package/2.directory-structure/3.tsconfig.md +3 -2
- package/2.directory-structure/index.md +12 -8
- package/3.guide/0.index.md +8 -2
- package/3.guide/1.concepts/{3.rendering.md → 1.rendering.md} +7 -32
- package/3.guide/1.concepts/{2.vuejs-development.md → 10.vuejs-development.md} +9 -8
- package/3.guide/1.concepts/{10.nuxt-lifecycle.md → 2.nuxt-lifecycle.md} +31 -24
- package/3.guide/1.concepts/{1.auto-imports.md → 3.auto-imports.md} +6 -6
- package/3.guide/1.concepts/4.server-engine.md +2 -2
- package/3.guide/1.concepts/5.modules.md +14 -1
- package/3.guide/1.concepts/7.esm.md +5 -4
- package/3.guide/1.concepts/8.typescript.md +9 -15
- package/3.guide/1.concepts/9.code-style.md +1 -1
- package/3.guide/2.best-practices/hydration.md +1 -1
- package/3.guide/2.best-practices/performance.md +5 -5
- package/3.guide/3.ai/.navigation.yml +3 -0
- package/3.guide/3.ai/1.mcp.md +277 -0
- package/3.guide/3.ai/2.llms-txt.md +65 -0
- package/3.guide/4.modules/.navigation.yml +3 -0
- package/3.guide/4.modules/1.getting-started.md +103 -0
- package/3.guide/4.modules/2.module-anatomy.md +138 -0
- package/3.guide/4.modules/3.recipes-basics.md +330 -0
- package/3.guide/4.modules/4.recipes-advanced.md +243 -0
- package/3.guide/4.modules/5.testing.md +76 -0
- package/3.guide/4.modules/6.best-practices.md +104 -0
- package/3.guide/4.modules/7.ecosystem.md +32 -0
- package/3.guide/4.modules/index.md +36 -0
- package/3.guide/{3.recipes → 5.recipes}/1.custom-routing.md +3 -3
- package/3.guide/{3.recipes → 5.recipes}/2.vite-plugin.md +4 -0
- package/3.guide/{3.recipes → 5.recipes}/3.custom-usefetch.md +2 -2
- package/3.guide/{3.recipes → 5.recipes}/4.sessions-and-authentication.md +2 -2
- package/3.guide/{4.going-further → 6.going-further}/1.events.md +3 -4
- package/3.guide/{4.going-further → 6.going-further}/1.experimental-features.md +211 -86
- package/3.guide/6.going-further/1.features.md +108 -0
- package/3.guide/{4.going-further → 6.going-further}/1.internals.md +4 -3
- package/3.guide/{4.going-further → 6.going-further}/10.runtime-config.md +2 -2
- package/3.guide/{4.going-further → 6.going-further}/11.nightly-release-channel.md +1 -1
- package/3.guide/{4.going-further → 6.going-further}/2.hooks.md +5 -5
- package/3.guide/{4.going-further → 6.going-further}/4.kit.md +3 -3
- package/3.guide/{4.going-further → 6.going-further}/6.nuxt-app.md +6 -6
- package/3.guide/{4.going-further → 6.going-further}/7.layers.md +31 -5
- package/3.guide/{4.going-further → 6.going-further}/9.debugging.md +3 -2
- package/4.api/1.components/1.nuxt-client-fallback.md +5 -1
- package/4.api/1.components/10.nuxt-picture.md +1 -1
- package/4.api/1.components/11.teleports.md +2 -2
- package/4.api/1.components/12.nuxt-route-announcer.md +0 -2
- package/4.api/1.components/13.nuxt-time.md +0 -2
- package/4.api/1.components/2.nuxt-page.md +3 -3
- package/4.api/1.components/3.nuxt-layout.md +6 -6
- package/4.api/1.components/4.nuxt-link.md +13 -13
- package/4.api/1.components/5.nuxt-loading-indicator.md +1 -1
- package/4.api/1.components/6.nuxt-error-boundary.md +2 -2
- package/4.api/1.components/7.nuxt-welcome.md +2 -2
- package/4.api/1.components/8.nuxt-island.md +9 -2
- package/4.api/2.composables/use-app-config.md +1 -1
- package/4.api/2.composables/use-async-data.md +5 -5
- package/4.api/2.composables/use-cookie.md +16 -16
- package/4.api/2.composables/use-error.md +3 -3
- package/4.api/2.composables/use-fetch.md +37 -37
- package/4.api/2.composables/use-head-safe.md +1 -1
- package/4.api/2.composables/use-head.md +22 -7
- package/4.api/2.composables/use-lazy-async-data.md +1 -1
- package/4.api/2.composables/use-lazy-fetch.md +9 -9
- package/4.api/2.composables/use-nuxt-app.md +9 -7
- package/4.api/2.composables/use-route-announcer.md +0 -2
- package/4.api/2.composables/use-route.md +2 -2
- package/4.api/2.composables/use-router.md +15 -15
- package/4.api/2.composables/use-runtime-config.md +5 -5
- package/4.api/2.composables/use-seo-meta.md +2 -2
- package/4.api/2.composables/use-server-seo-meta.md +2 -2
- package/4.api/2.composables/use-state.md +12 -2
- package/4.api/3.utils/$fetch.md +1 -1
- package/4.api/3.utils/abort-navigation.md +2 -2
- package/4.api/3.utils/call-once.md +2 -4
- package/4.api/3.utils/clear-error.md +1 -1
- package/4.api/3.utils/create-error.md +7 -7
- package/4.api/3.utils/define-lazy-hydration-component.md +5 -5
- package/4.api/3.utils/define-nuxt-component.md +1 -1
- package/4.api/3.utils/define-nuxt-plugin.md +12 -12
- package/4.api/3.utils/define-nuxt-route-middleware.md +2 -2
- package/4.api/3.utils/define-page-meta.md +18 -11
- package/4.api/3.utils/define-route-rules.md +2 -2
- package/4.api/3.utils/navigate-to.md +14 -14
- package/4.api/3.utils/on-before-route-leave.md +1 -1
- package/4.api/3.utils/on-before-route-update.md +1 -1
- package/4.api/3.utils/preload-route-components.md +2 -2
- package/4.api/3.utils/refresh-cookie.md +0 -2
- package/4.api/3.utils/refresh-nuxt-data.md +1 -1
- package/4.api/3.utils/reload-nuxt-app.md +1 -1
- package/4.api/3.utils/set-page-layout.md +36 -0
- package/4.api/3.utils/set-response-status.md +3 -3
- package/4.api/3.utils/show-error.md +4 -4
- package/4.api/3.utils/update-app-config.md +1 -1
- package/4.api/4.commands/add.md +11 -11
- package/4.api/4.commands/analyze.md +11 -11
- package/4.api/4.commands/build-module.md +11 -11
- package/4.api/4.commands/build.md +12 -12
- package/4.api/4.commands/cleanup.md +6 -6
- package/4.api/4.commands/dev.md +23 -23
- package/4.api/4.commands/devtools.md +7 -7
- package/4.api/4.commands/generate.md +12 -12
- package/4.api/4.commands/info.md +6 -6
- package/4.api/4.commands/init.md +18 -18
- package/4.api/4.commands/module.md +18 -18
- package/4.api/4.commands/prepare.md +10 -10
- package/4.api/4.commands/preview.md +11 -11
- package/4.api/4.commands/test.md +9 -9
- package/4.api/4.commands/typecheck.md +10 -10
- package/4.api/4.commands/upgrade.md +10 -10
- package/4.api/5.kit/1.modules.md +31 -18
- package/4.api/5.kit/10.templates.md +23 -23
- package/4.api/5.kit/11.nitro.md +36 -36
- package/4.api/5.kit/12.resolving.md +2 -2
- package/4.api/5.kit/14.builder.md +35 -23
- package/4.api/5.kit/16.layers.md +16 -16
- package/4.api/5.kit/2.programmatic.md +2 -2
- package/4.api/5.kit/3.compatibility.md +2 -2
- package/4.api/5.kit/4.autoimports.md +18 -18
- package/4.api/5.kit/5.components.md +35 -35
- package/4.api/5.kit/6.context.md +1 -1
- package/4.api/5.kit/8.layout.md +1 -1
- package/4.api/6.advanced/1.hooks.md +85 -85
- package/4.api/index.md +7 -7
- package/5.community/4.contribution.md +10 -10
- package/5.community/5.framework-contribution.md +9 -9
- package/5.community/6.roadmap.md +25 -25
- package/5.community/7.changelog.md +10 -0
- package/6.bridge/1.overview.md +8 -0
- package/6.bridge/3.bridge-composition-api.md +2 -2
- package/6.bridge/4.plugins-and-middleware.md +2 -2
- package/6.bridge/5.nuxt3-compatible-api.md +1 -1
- package/6.bridge/8.nitro.md +4 -0
- package/7.migration/10.bundling.md +1 -1
- package/7.migration/11.server.md +3 -3
- package/7.migration/2.configuration.md +5 -5
- package/7.migration/20.module-authors.md +3 -3
- package/7.migration/4.meta.md +1 -1
- package/7.migration/5.plugins-and-middleware.md +3 -3
- package/7.migration/6.pages-and-layouts.md +5 -5
- package/7.migration/7.component-options.md +6 -6
- package/7.migration/8.runtime-config.md +1 -1
- package/package.json +1 -1
- package/3.guide/4.going-further/1.features.md +0 -103
- package/3.guide/4.going-further/3.modules.md +0 -901
- /package/3.guide/{3.recipes → 5.recipes}/.navigation.yml +0 -0
- /package/3.guide/{4.going-further → 6.going-further}/.navigation.yml +0 -0
- /package/3.guide/{4.going-further → 6.going-further}/index.md +0 -0
|
@@ -9,7 +9,7 @@ The hooking system is powered by [unjs/hookable](https://github.com/unjs/hookabl
|
|
|
9
9
|
|
|
10
10
|
## Nuxt Hooks (Build Time)
|
|
11
11
|
|
|
12
|
-
These hooks are available for [Nuxt
|
|
12
|
+
These hooks are available for [Nuxt modules](/docs/3.x/guide/modules) and build context.
|
|
13
13
|
|
|
14
14
|
### Within `nuxt.config.ts`
|
|
15
15
|
|
|
@@ -33,7 +33,7 @@ export default defineNuxtModule({
|
|
|
33
33
|
})
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
::read-more{to="/docs/api/advanced/hooks#nuxt-hooks-build-time"}
|
|
36
|
+
::read-more{to="/docs/3.x/api/advanced/hooks#nuxt-hooks-build-time"}
|
|
37
37
|
Explore all available Nuxt hooks.
|
|
38
38
|
::
|
|
39
39
|
|
|
@@ -49,7 +49,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
49
49
|
})
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
::read-more{to="/docs/api/advanced/hooks#app-hooks-runtime"}
|
|
52
|
+
::read-more{to="/docs/3.x/api/advanced/hooks#app-hooks-runtime"}
|
|
53
53
|
Explore all available App hooks.
|
|
54
54
|
::
|
|
55
55
|
|
|
@@ -70,7 +70,7 @@ export default defineNitroPlugin((nitroApp) => {
|
|
|
70
70
|
})
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
::read-more{to="/docs/api/advanced/hooks#nitro-app-hooks-runtime-server-side"}
|
|
73
|
+
::read-more{to="/docs/3.x/api/advanced/hooks#nitro-app-hooks-runtime-server-side"}
|
|
74
74
|
Learn more about available Nitro lifecycle hooks.
|
|
75
75
|
::
|
|
76
76
|
|
|
@@ -90,7 +90,7 @@ declare module '#app' {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
declare module 'nitropack' {
|
|
93
|
+
declare module 'nitropack/types' {
|
|
94
94
|
interface NitroRuntimeHooks {
|
|
95
95
|
'your-nitro-hook': () => void
|
|
96
96
|
}
|
|
@@ -3,9 +3,9 @@ title: "Nuxt Kit"
|
|
|
3
3
|
description: "@nuxt/kit provides features for module authors."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
Nuxt Kit provides composable utilities to make interacting with [Nuxt Hooks](/docs/3.x/api/advanced/hooks), the [Nuxt Interface](/docs/3.x/guide/going-further/internals#the-nuxt-interface) and developing [Nuxt
|
|
6
|
+
Nuxt Kit provides composable utilities to make interacting with [Nuxt Hooks](/docs/3.x/api/advanced/hooks), the [Nuxt Interface](/docs/3.x/guide/going-further/internals#the-nuxt-interface) and developing [Nuxt modules](/docs/3.x/guide/modules) super easy.
|
|
7
7
|
|
|
8
|
-
::read-more{to="/docs/api/kit"}
|
|
8
|
+
::read-more{to="/docs/3.x/api/kit"}
|
|
9
9
|
Discover all Nuxt Kit utilities.
|
|
10
10
|
::
|
|
11
11
|
|
|
@@ -33,7 +33,7 @@ You can install the latest Nuxt Kit by adding it to the `dependencies` section o
|
|
|
33
33
|
import { useNuxt } from '@nuxt/kit'
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
:read-more{to="/docs/api/kit"}
|
|
36
|
+
:read-more{to="/docs/3.x/api/kit"}
|
|
37
37
|
|
|
38
38
|
::note
|
|
39
39
|
Nuxt Kit utilities are only available for modules and not meant to be imported in runtime (components, Vue composables, pages, plugins, or server routes).
|
|
@@ -9,13 +9,13 @@ 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
|
|
|
16
16
|
## Nuxt App Interface
|
|
17
17
|
|
|
18
|
-
::read-more{to="/docs/guide/going-further/internals#the-nuxtapp-interface"}
|
|
18
|
+
::read-more{to="/docs/3.x/guide/going-further/internals#the-nuxtapp-interface"}
|
|
19
19
|
Jump over the `NuxtApp` interface documentation.
|
|
20
20
|
::
|
|
21
21
|
|
|
@@ -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/3.x/directory-structure/plugins), [Nuxt hooks](/docs/3.x/guide/going-further/hooks), [Nuxt middleware](/docs/3.x/directory-structure/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/3.x/directory-structure/plugins), [Nuxt hooks](/docs/3.x/guide/going-further/hooks), [Nuxt middleware](/docs/3.x/directory-structure/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/3.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/
|
|
45
|
+
:read-more{to="/docs/3.x/directory-structure/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/
|
|
58
|
+
::read-more{to="/docs/3.x/directory-structure/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
|
::
|
|
@@ -5,7 +5,7 @@ description: Nuxt provides a powerful system that allows you to extend the defau
|
|
|
5
5
|
|
|
6
6
|
Nuxt layers are a powerful feature that you can use to share and reuse partial Nuxt applications within a monorepo, or from a git repository or npm package. The layers structure is almost identical to a standard Nuxt application, which makes them easy to author and maintain.
|
|
7
7
|
|
|
8
|
-
:read-more{to="/docs/getting-started/layers"}
|
|
8
|
+
:read-more{to="/docs/3.x/getting-started/layers"}
|
|
9
9
|
|
|
10
10
|
A minimal Nuxt layer directory should contain a [`nuxt.config.ts`](/docs/3.x/directory-structure/nuxt-config) file to indicate it is a layer.
|
|
11
11
|
|
|
@@ -21,14 +21,14 @@ Additionally, certain other files in the layer directory will be auto-scanned an
|
|
|
21
21
|
- [`middleware/*`](/docs/3.x/directory-structure/middleware) - Extend the default middleware
|
|
22
22
|
- [`pages/*`](/docs/3.x/directory-structure/pages) - Extend the default pages
|
|
23
23
|
- [`plugins/*`](/docs/3.x/directory-structure/plugins) - Extend the default plugins
|
|
24
|
-
- [`server/*`](/docs/3.x/directory-structure/server) - Extend the default server endpoints & middleware
|
|
25
24
|
- [`utils/*`](/docs/3.x/directory-structure/utils) - Extend the default utils
|
|
26
|
-
- [`nuxt.config.ts`](/docs/3.x/directory-structure/nuxt-config)- Extend the default nuxt config
|
|
27
25
|
- [`app.config.ts`](/docs/3.x/directory-structure/app-config) - Extend the default app config
|
|
26
|
+
- [`server/*`](/docs/3.x/directory-structure/server) - Extend the default server endpoints & middleware
|
|
27
|
+
- [`nuxt.config.ts`](/docs/3.x/directory-structure/nuxt-config)- Extend the default nuxt config
|
|
28
28
|
|
|
29
29
|
## Basic Example
|
|
30
30
|
|
|
31
|
-
::code-
|
|
31
|
+
::code-tree{defaultValue="nuxt.config.ts" expandAll}
|
|
32
32
|
|
|
33
33
|
```ts [nuxt.config.ts]
|
|
34
34
|
export default defineNuxtConfig({
|
|
@@ -249,9 +249,35 @@ export default defineNuxtConfig({
|
|
|
249
249
|
})
|
|
250
250
|
```
|
|
251
251
|
|
|
252
|
+
## Disabling Modules from Layers
|
|
253
|
+
|
|
254
|
+
When extending a layer, you might want to disable certain modules that it includes. You can do this by setting the module's config key to `false` in your Nuxt config.
|
|
255
|
+
|
|
256
|
+
```ts [nuxt.config.ts]
|
|
257
|
+
export default defineNuxtConfig({
|
|
258
|
+
extends: ['./base-layer'],
|
|
259
|
+
// Disable modules from the layer by setting their config key to false
|
|
260
|
+
image: false, // Disables @nuxt/image
|
|
261
|
+
pinia: false, // Disables @pinia/nuxt
|
|
262
|
+
})
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
::note
|
|
266
|
+
The config key is defined by each module. Common examples include `image` for `@nuxt/image`, `pinia` for `@pinia/nuxt`, and `content` for `@nuxt/content`. Check the module's documentation for its specific config key.
|
|
267
|
+
::
|
|
268
|
+
|
|
269
|
+
This is useful when:
|
|
270
|
+
- A layer includes modules you don't need in your project
|
|
271
|
+
- You want to use a different implementation than what the layer provides
|
|
272
|
+
- You need to disable analytics or other modules in specific environments
|
|
273
|
+
|
|
274
|
+
::tip
|
|
275
|
+
You can also use this approach to disable modules in your own project - not just those from layers. Setting a module's config key to `false` will prevent its setup function from running while still generating types for the module.
|
|
276
|
+
::
|
|
277
|
+
|
|
252
278
|
## Multi-Layer Support for Nuxt Modules
|
|
253
279
|
|
|
254
|
-
You can use the [`getLayerDirectories`](/docs/api/kit/layers#getlayerdirectories) utility from Nuxt Kit to support custom multi-layer handling for your modules.
|
|
280
|
+
You can use the [`getLayerDirectories`](/docs/3.x/api/kit/layers#getlayerdirectories) utility from Nuxt Kit to support custom multi-layer handling for your modules.
|
|
255
281
|
|
|
256
282
|
```ts [modules/my-module.ts]
|
|
257
283
|
import { defineNuxtModule, getLayerDirectories } from 'nuxt/kit'
|
|
@@ -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
|
{
|
|
@@ -49,7 +49,8 @@ You may need to update the config below with a path to your web browser. For mor
|
|
|
49
49
|
"request": "launch",
|
|
50
50
|
"name": "client: chrome",
|
|
51
51
|
"url": "http://localhost:3000",
|
|
52
|
-
|
|
52
|
+
// this should point to your Nuxt `srcDir`, which is `app` by default
|
|
53
|
+
"webRoot": "${workspaceFolder}/app"
|
|
53
54
|
},
|
|
54
55
|
{
|
|
55
56
|
"type": "node",
|
|
@@ -14,7 +14,7 @@ links:
|
|
|
14
14
|
|
|
15
15
|
Nuxt provides the `<NuxtClientFallback>` component to render its content on the client if any of its children trigger an error in SSR.
|
|
16
16
|
|
|
17
|
-
::note{to="/docs/guide/going-further/experimental-features#clientfallback"}
|
|
17
|
+
::note{to="/docs/3.x/guide/going-further/experimental-features#clientfallback"}
|
|
18
18
|
This component is experimental and in order to use it you must enable the `experimental.clientFallback` option in your `nuxt.config`.
|
|
19
19
|
::
|
|
20
20
|
|
|
@@ -54,6 +54,10 @@ This component is experimental and in order to use it you must enable the `exper
|
|
|
54
54
|
- **type**: `boolean`
|
|
55
55
|
- **default**: `false`
|
|
56
56
|
|
|
57
|
+
::warning{icon="i-ph-warning-duotone"}
|
|
58
|
+
The `placeholder` and `fallback` props render content as raw HTML. Do not pass untrusted user input to these props as it may lead to XSS vulnerabilities. Use the `#fallback` or `#placeholder` slots instead for dynamic content that needs proper escaping.
|
|
59
|
+
::
|
|
60
|
+
|
|
57
61
|
```vue
|
|
58
62
|
<template>
|
|
59
63
|
<!-- render <span>Hello world</span> server-side if the default slot fails to render -->
|
|
@@ -12,7 +12,7 @@ links:
|
|
|
12
12
|
|
|
13
13
|
Usage of `<NuxtPicture>` is almost identical to [`<NuxtImg>`](/docs/3.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
|
|
@@ -40,4 +40,4 @@ The `to` target of [`<Teleport>`](https://vuejs.org/guide/built-ins/teleport.htm
|
|
|
40
40
|
</template>
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
:link-example{to="/docs/examples/advanced/teleport"}
|
|
43
|
+
:link-example{to="/docs/3.x/examples/advanced/teleport"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: '<NuxtRouteAnnouncer>'
|
|
3
3
|
description: 'The <NuxtRouteAnnouncer> component adds a hidden element with the page title to announce route changes to assistive technologies.'
|
|
4
|
-
navigation:
|
|
5
|
-
badge: New
|
|
6
4
|
links:
|
|
7
5
|
- label: Source
|
|
8
6
|
icon: i-simple-icons-github
|
|
@@ -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 [`pages/`](/docs/3.x/directory-structure/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:
|
|
@@ -89,7 +89,7 @@ definePageMeta({
|
|
|
89
89
|
</script>
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
-
:link-example{to="/docs/examples/routing/pages"}
|
|
92
|
+
:link-example{to="/docs/3.x/examples/routing/pages"}
|
|
93
93
|
|
|
94
94
|
## Page's Ref
|
|
95
95
|
|
|
@@ -151,4 +151,4 @@ console.log(attrs.foobar) // Outputs: 123
|
|
|
151
151
|
</script>
|
|
152
152
|
```
|
|
153
153
|
|
|
154
|
-
:read-more{to="/docs/
|
|
154
|
+
:read-more{to="/docs/3.x/directory-structure/pages"}
|
|
@@ -18,12 +18,12 @@ You can use `<NuxtLayout />` component to activate the `default` layout on `app.
|
|
|
18
18
|
</template>
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
:read-more{to="/docs/
|
|
21
|
+
:read-more{to="/docs/3.x/directory-structure/layouts"}
|
|
22
22
|
|
|
23
23
|
## Props
|
|
24
24
|
|
|
25
|
-
- `name`: Specify a layout name to be rendered, can be a string, reactive reference or a computed property. It **must** match the name of the corresponding layout file in the [`layouts/`](/docs/3.x/directory-structure/layouts) directory.
|
|
26
|
-
- **type**: `string`
|
|
25
|
+
- `name`: Specify a layout name to be rendered, can be a string, reactive reference or a computed property. It **must** match the name of the corresponding layout file in the [`layouts/`](/docs/3.x/directory-structure/layouts) directory, or `false` to disable the layout.
|
|
26
|
+
- **type**: `string | false`
|
|
27
27
|
- **default**: `default`
|
|
28
28
|
|
|
29
29
|
```vue [pages/index.vue]
|
|
@@ -51,7 +51,7 @@ Please note the layout name is normalized to kebab-case, so if your layout file
|
|
|
51
51
|
</template>
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
::read-more{to="/docs/
|
|
54
|
+
::read-more{to="/docs/3.x/directory-structure/layouts"}
|
|
55
55
|
Read more about dynamic layouts.
|
|
56
56
|
::
|
|
57
57
|
|
|
@@ -116,7 +116,7 @@ console.log(layoutCustomProps.title) // I am a custom layout
|
|
|
116
116
|
|
|
117
117
|
::
|
|
118
118
|
|
|
119
|
-
:read-more{to="/docs/getting-started/transitions"}
|
|
119
|
+
:read-more{to="/docs/3.x/getting-started/transitions"}
|
|
120
120
|
|
|
121
121
|
## Layout's Ref
|
|
122
122
|
|
|
@@ -158,4 +158,4 @@ defineExpose({
|
|
|
158
158
|
|
|
159
159
|
::
|
|
160
160
|
|
|
161
|
-
:read-more{to="/docs/
|
|
161
|
+
:read-more{to="/docs/3.x/directory-structure/layouts"}
|
|
@@ -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/3.x/
|
|
261
|
+
- `prefetch`: When enabled will prefetch middleware, layouts and payloads (when using [payloadExtraction](/docs/3.x/guide/going-further/experimental-features#payloadextraction)) of links in the viewport. Used by the experimental [crossOriginPrefetch](/docs/3.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.
|
|
@@ -269,14 +269,14 @@ When not using `external`, `<NuxtLink>` supports all Vue Router's [`RouterLink`
|
|
|
269
269
|
- `rel`: A `rel` attribute value to apply on the link. Defaults to `"noopener noreferrer"` for external links.
|
|
270
270
|
|
|
271
271
|
::tip
|
|
272
|
-
Defaults can be overwritten, see [overwriting defaults](#overwriting-defaults) if you want to change them.
|
|
272
|
+
Defaults can be overwritten, see [overwriting defaults](/docs/3.x/api/components/nuxt-link#overwriting-defaults) if you want to change them.
|
|
273
273
|
::
|
|
274
274
|
|
|
275
275
|
## Overwriting Defaults
|
|
276
276
|
|
|
277
277
|
### In Nuxt Config
|
|
278
278
|
|
|
279
|
-
You can overwrite some `<NuxtLink>` defaults in your [`nuxt.config`](/docs/3.x/
|
|
279
|
+
You can overwrite some `<NuxtLink>` defaults in your [`nuxt.config`](/docs/3.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,11 +336,11 @@ 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.
|
|
344
344
|
- `prefetchedClass`: A default class to apply to links that have been prefetched.
|
|
345
345
|
|
|
346
|
-
:link-example{to="/docs/examples/routing/pages"}
|
|
346
|
+
:link-example{to="/docs/3.x/examples/routing/pages"}
|
|
@@ -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
|
|
@@ -43,7 +43,7 @@ The `<NuxtErrorBoundary>` uses Vue's [`onErrorCaptured`](https://vuejs.org/api/c
|
|
|
43
43
|
</template>
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
:read-more{to="/docs/getting-started/error-handling"}
|
|
46
|
+
:read-more{to="/docs/3.x/getting-started/error-handling"}
|
|
47
47
|
|
|
48
48
|
## Examples
|
|
49
49
|
|
|
@@ -4,7 +4,7 @@ description: The <NuxtWelcome> component greets users in new projects made from
|
|
|
4
4
|
links:
|
|
5
5
|
- label: Source
|
|
6
6
|
icon: i-simple-icons-github
|
|
7
|
-
to: https://github.com/nuxt/
|
|
7
|
+
to: https://github.com/nuxt/nuxt/blob/main/packages/ui-templates/templates/welcome/index.html
|
|
8
8
|
size: xs
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -21,5 +21,5 @@ Preview the `<NuxtWelcome />` component.
|
|
|
21
21
|
::
|
|
22
22
|
|
|
23
23
|
::tip
|
|
24
|
-
This component is part of [nuxt/
|
|
24
|
+
This component is part of [`@nuxt/ui-templates`](https://github.com/nuxt/nuxt/tree/main/packages/ui-templates) package.
|
|
25
25
|
::
|
|
@@ -32,13 +32,20 @@ Server only components use `<NuxtIsland>` under the hood
|
|
|
32
32
|
- **type**: `Record<string, any>`
|
|
33
33
|
- `source`: Remote source to call the island to render.
|
|
34
34
|
- **type**: `string`
|
|
35
|
-
- **dangerouslyLoadClientComponents**: Required to load components from a remote source.
|
|
35
|
+
- **dangerouslyLoadClientComponents**: Required to load client components from a remote source.
|
|
36
36
|
- **type**: `boolean`
|
|
37
37
|
- **default**: `false`
|
|
38
38
|
|
|
39
39
|
::note
|
|
40
40
|
Remote islands need `experimental.componentIslands` to be `'local+remote'` in your `nuxt.config`.
|
|
41
|
-
|
|
41
|
+
::
|
|
42
|
+
|
|
43
|
+
::warning{icon="i-ph-warning-duotone"}
|
|
44
|
+
Using the `source` prop to render content from a remote server is inherently dangerous. When you specify a remote `source`, you are fully trusting that server to provide safe HTML content that will be rendered directly in your application.
|
|
45
|
+
|
|
46
|
+
This is similar to using `v-html` with external content - the remote server can inject any HTML, including potentially malicious content. **Only use `source` with servers you fully trust and control.**
|
|
47
|
+
|
|
48
|
+
The `dangerouslyLoadClientComponents` prop controls an additional layer of risk: whether to also download and execute client components from the remote source. Even with `dangerouslyLoadClientComponents` disabled (the default), you are still trusting the remote server's HTML output.
|
|
42
49
|
::
|
|
43
50
|
|
|
44
51
|
::note
|
|
@@ -25,8 +25,8 @@ const { data, status, pending, error, refresh, clear } = await useAsyncData(
|
|
|
25
25
|
</script>
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
::warning
|
|
29
|
-
If you're using a custom useAsyncData wrapper, do not await it in the composable
|
|
28
|
+
::warning{to="/docs/3.x/guide/recipes/custom-usefetch#custom-usefetchuseasyncdata"}
|
|
29
|
+
If you're using a custom `useAsyncData` wrapper, do not await it in the composable as that can cause unexpected behavior. See recipe for custom async data fetcher.
|
|
30
30
|
::
|
|
31
31
|
|
|
32
32
|
::note
|
|
@@ -133,7 +133,7 @@ The handler signal will be aborted when:
|
|
|
133
133
|
[`useAsyncData`](/docs/3.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/3.x/api/composables/use-async-data).
|
|
134
134
|
::
|
|
135
135
|
|
|
136
|
-
:read-more{to="/docs/getting-started/data-fetching#useasyncdata"}
|
|
136
|
+
:read-more{to="/docs/3.x/getting-started/data-fetching#useasyncdata"}
|
|
137
137
|
|
|
138
138
|
## Params
|
|
139
139
|
|
|
@@ -167,7 +167,7 @@ The `handler` function should be **side-effect free** to ensure predictable beha
|
|
|
167
167
|
Under the hood, `lazy: false` uses `<Suspense>` to block the loading of the route before the data has been fetched. Consider using `lazy: true` and implementing a loading state instead for a snappier user experience.
|
|
168
168
|
::
|
|
169
169
|
|
|
170
|
-
::read-more{to="/docs/api/composables/use-lazy-async-data"}
|
|
170
|
+
::read-more{to="/docs/3.x/api/composables/use-lazy-async-data"}
|
|
171
171
|
You can use `useLazyAsyncData` to have the same behavior as `lazy: true` with `useAsyncData`.
|
|
172
172
|
::
|
|
173
173
|
|
|
@@ -280,4 +280,4 @@ interface AsyncDataExecuteOptions {
|
|
|
280
280
|
type AsyncDataRequestStatus = 'idle' | 'pending' | 'success' | 'error'
|
|
281
281
|
```
|
|
282
282
|
|
|
283
|
-
:read-more{to="/docs/getting-started/data-fetching"}
|
|
283
|
+
:read-more{to="/docs/3.x/getting-started/data-fetching"}
|
|
@@ -54,21 +54,21 @@ export function useCookie<T = string | null | undefined> (
|
|
|
54
54
|
|
|
55
55
|
Most of the options will be directly passed to the [cookie](https://github.com/jshttp/cookie) package.
|
|
56
56
|
|
|
57
|
-
| Property
|
|
58
|
-
|
|
59
|
-
| `decode`
|
|
60
|
-
| `encode`
|
|
61
|
-
| `default`
|
|
62
|
-
| `watch`
|
|
63
|
-
| `readonly`
|
|
64
|
-
| `maxAge`
|
|
65
|
-
| `expires`
|
|
66
|
-
| `httpOnly`
|
|
67
|
-
| `secure`
|
|
68
|
-
| `partitioned` | `boolean`
|
|
69
|
-
| `domain`
|
|
70
|
-
| `path`
|
|
71
|
-
| `sameSite`
|
|
57
|
+
| Property | Type | Default | Description |
|
|
58
|
+
|---------------|------------------------|----------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
59
|
+
| `decode` | `(value: string) => T` | `decodeURIComponent` + [destr](https://github.com/unjs/destr). | Custom function to decode the cookie value. Since the value of a cookie has a limited character set (and must be a simple string), this function can be used to decode a previously encoded cookie value into a JavaScript string or other object. <br/> **Note:** If an error is thrown from this function, the original, non-decoded cookie value will be returned as the cookie's value. |
|
|
60
|
+
| `encode` | `(value: T) => string` | `JSON.stringify` + `encodeURIComponent` | Custom function to encode the cookie value. Since the value of a cookie has a limited character set (and must be a simple string), this function can be used to encode a value into a string suited for a cookie's value. |
|
|
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
|
+
| `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/3.x/api/utils/refresh-cookie). |
|
|
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://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
|
+
| `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://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
|
+
| `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://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
|
|
|
@@ -180,4 +180,4 @@ export default defineEventHandler((event) => {
|
|
|
180
180
|
})
|
|
181
181
|
```
|
|
182
182
|
|
|
183
|
-
:link-example{to="/docs/examples/advanced/use-cookie"}
|
|
183
|
+
:link-example{to="/docs/3.x/examples/advanced/use-cookie"}
|
|
@@ -22,8 +22,8 @@ You can use this composable in your components, pages, or plugins to access or r
|
|
|
22
22
|
|
|
23
23
|
```ts
|
|
24
24
|
interface NuxtError<DataT = unknown> {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
status: number
|
|
26
|
+
statusText: string
|
|
27
27
|
message: string
|
|
28
28
|
data?: DataT
|
|
29
29
|
error?: true
|
|
@@ -52,4 +52,4 @@ if (error.value) {
|
|
|
52
52
|
</script>
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
:read-more{to="/docs/getting-started/error-handling"}
|
|
55
|
+
:read-more{to="/docs/3.x/getting-started/error-handling"}
|