@nuxt/docs 4.2.0 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/1.getting-started/02.installation.md +3 -3
  2. package/1.getting-started/03.configuration.md +4 -4
  3. package/1.getting-started/04.views.md +2 -2
  4. package/1.getting-started/05.assets.md +1 -1
  5. package/1.getting-started/06.styling.md +11 -11
  6. package/1.getting-started/07.routing.md +4 -0
  7. package/1.getting-started/09.transitions.md +6 -6
  8. package/1.getting-started/10.data-fetching.md +14 -14
  9. package/1.getting-started/11.state-management.md +2 -2
  10. package/1.getting-started/12.error-handling.md +4 -4
  11. package/1.getting-started/13.server.md +4 -4
  12. package/1.getting-started/14.layers.md +29 -10
  13. package/1.getting-started/17.testing.md +3 -3
  14. package/1.getting-started/18.upgrade.md +19 -11
  15. package/2.guide/1.directory-structure/1.app/1.components.md +4 -4
  16. package/2.guide/1.directory-structure/1.app/1.composables.md +1 -1
  17. package/2.guide/1.directory-structure/1.app/1.layouts.md +2 -2
  18. package/2.guide/1.directory-structure/1.app/1.middleware.md +4 -4
  19. package/2.guide/1.directory-structure/1.app/1.pages.md +13 -13
  20. package/2.guide/1.directory-structure/1.app/1.plugins.md +1 -5
  21. package/2.guide/1.directory-structure/1.node_modules.md +1 -1
  22. package/2.guide/1.directory-structure/1.public.md +1 -1
  23. package/2.guide/1.directory-structure/1.server.md +5 -5
  24. package/2.guide/1.directory-structure/2.env.md +1 -1
  25. package/2.guide/1.directory-structure/3.tsconfig.md +38 -7
  26. package/2.guide/2.concepts/1.auto-imports.md +2 -2
  27. package/2.guide/2.concepts/10.nuxt-lifecycle.md +3 -3
  28. package/2.guide/2.concepts/2.vuejs-development.md +3 -3
  29. package/2.guide/2.concepts/3.rendering.md +4 -4
  30. package/2.guide/2.concepts/7.esm.md +2 -2
  31. package/2.guide/2.concepts/8.typescript.md +15 -38
  32. package/2.guide/2.concepts/9.code-style.md +1 -1
  33. package/2.guide/3.going-further/1.experimental-features.md +6 -6
  34. package/2.guide/3.going-further/1.features.md +1 -1
  35. package/2.guide/3.going-further/1.internals.md +2 -2
  36. package/2.guide/3.going-further/2.hooks.md +1 -1
  37. package/2.guide/3.going-further/3.modules.md +77 -10
  38. package/2.guide/3.going-further/6.nuxt-app.md +5 -5
  39. package/2.guide/3.going-further/7.layers.md +32 -15
  40. package/2.guide/3.going-further/9.debugging.md +1 -1
  41. package/2.guide/4.recipes/1.custom-routing.md +4 -4
  42. package/2.guide/4.recipes/3.custom-usefetch.md +1 -1
  43. package/2.guide/5.best-practices/hydration.md +1 -1
  44. package/3.api/1.components/10.nuxt-picture.md +1 -1
  45. package/3.api/1.components/11.teleports.md +1 -1
  46. package/3.api/1.components/12.nuxt-route-announcer.md +1 -1
  47. package/3.api/1.components/2.nuxt-page.md +1 -1
  48. package/3.api/1.components/4.nuxt-link.md +11 -11
  49. package/3.api/1.components/5.nuxt-loading-indicator.md +1 -1
  50. package/3.api/1.components/6.nuxt-error-boundary.md +1 -1
  51. package/3.api/2.composables/use-app-config.md +1 -1
  52. package/3.api/2.composables/use-async-data.md +76 -13
  53. package/3.api/2.composables/use-cookie.md +7 -7
  54. package/3.api/2.composables/use-fetch.md +2 -2
  55. package/3.api/2.composables/use-head-safe.md +37 -20
  56. package/3.api/2.composables/use-head.md +136 -36
  57. package/3.api/2.composables/use-hydration.md +24 -18
  58. package/3.api/2.composables/use-lazy-async-data.md +58 -9
  59. package/3.api/2.composables/use-lazy-fetch.md +65 -9
  60. package/3.api/2.composables/use-nuxt-app.md +7 -7
  61. package/3.api/2.composables/use-nuxt-data.md +1 -1
  62. package/3.api/2.composables/use-request-fetch.md +1 -1
  63. package/3.api/2.composables/use-route.md +1 -1
  64. package/3.api/2.composables/use-router.md +15 -15
  65. package/3.api/2.composables/use-runtime-hook.md +1 -1
  66. package/3.api/2.composables/use-state.md +1 -1
  67. package/3.api/3.utils/abort-navigation.md +2 -2
  68. package/3.api/3.utils/define-lazy-hydration-component.md +4 -4
  69. package/3.api/3.utils/define-nuxt-component.md +1 -1
  70. package/3.api/3.utils/define-nuxt-plugin.md +1 -1
  71. package/3.api/3.utils/define-nuxt-route-middleware.md +1 -1
  72. package/3.api/3.utils/define-page-meta.md +8 -8
  73. package/3.api/3.utils/navigate-to.md +5 -5
  74. package/3.api/3.utils/on-before-route-leave.md +1 -1
  75. package/3.api/3.utils/on-before-route-update.md +1 -1
  76. package/3.api/3.utils/refresh-cookie.md +1 -1
  77. package/3.api/3.utils/update-app-config.md +2 -2
  78. package/3.api/5.kit/1.modules.md +3 -3
  79. package/3.api/5.kit/14.builder.md +6 -6
  80. package/3.api/5.kit/2.programmatic.md +2 -2
  81. package/3.api/6.advanced/1.hooks.md +5 -5
  82. package/3.api/6.nuxt-config.md +25 -25
  83. package/5.community/3.reporting-bugs.md +1 -1
  84. package/5.community/4.contribution.md +1 -1
  85. package/5.community/5.framework-contribution.md +8 -8
  86. package/5.community/6.roadmap.md +3 -3
  87. package/6.bridge/4.plugins-and-middleware.md +1 -1
  88. package/7.migration/2.configuration.md +2 -2
  89. package/7.migration/20.module-authors.md +1 -1
  90. package/7.migration/5.plugins-and-middleware.md +1 -1
  91. package/7.migration/6.pages-and-layouts.md +2 -2
  92. package/README.md +1 -1
  93. package/package.json +1 -1
@@ -224,7 +224,7 @@ Modules, like everything in a Nuxt configuration, aren't included in your applic
224
224
  Inside the runtime directory, you can provide any kind of assets related to the Nuxt App:
225
225
  - Vue components
226
226
  - Composables
227
- - [Nuxt plugins](/docs/4.x/guide/directory-structure/plugins)
227
+ - [Nuxt plugins](/docs/4.x/guide/directory-structure/app/plugins)
228
228
 
229
229
  To the [server engine](/docs/4.x/guide/concepts/server-engine), Nitro:
230
230
  - API routes
@@ -653,6 +653,19 @@ export default defineNuxtModule({
653
653
  })
654
654
  ```
655
655
 
656
+ #### Updating Templates
657
+
658
+ If you need to update your templates/virtual files, you can leverage the `updateTemplates` utility like this:
659
+
660
+ ```ts
661
+ nuxt.hook('builder:watch', (event, path) => {
662
+ if (path.includes('my-module-feature.config')) {
663
+ // This will reload the template that you registered
664
+ updateTemplates({ filter: t => t.filename === 'my-module-feature.mjs' })
665
+ }
666
+ })
667
+ ```
668
+
656
669
  #### Adding Type Declarations
657
670
 
658
671
  You might also want to add a type declaration to the user's project (for example, to augment a Nuxt interface
@@ -691,19 +704,73 @@ nuxt.hook('prepare:types', ({ references }) => {
691
704
  })
692
705
  ```
693
706
 
694
- ##### Updating Templates
707
+ #### Extending `tsconfig.json`
708
+
709
+ There are multiple ways to extend the TypeScript configuration of the user's project from your module.
695
710
 
696
- If you need to update your templates/virtual files, you can leverage the `updateTemplates` utility like this :
711
+ The simplest way is to modify the Nuxt configuration directly like this:
697
712
 
713
+ <!-- @case-police-ignore tsConfig -->
698
714
  ```ts
699
- nuxt.hook('builder:watch', (event, path) => {
700
- if (path.includes('my-module-feature.config')) {
701
- // This will reload the template that you registered
702
- updateTemplates({ filter: t => t.filename === 'my-module-feature.mjs' })
703
- }
715
+ // extend tsconfig.app.json
716
+ nuxt.options.typescript.tsConfig.include ??= []
717
+ nuxt.options.typescript.tsConfig.include.push(resolve('./augments.d.ts'))
718
+
719
+ // extend tsconfig.shared.json
720
+ nuxt.options.typescript.sharedTsConfig.include ??= []
721
+ nuxt.options.typescript.sharedTsConfig.include.push(resolve('./augments.d.ts'))
722
+
723
+ // extend tsconfig.node.json
724
+ nuxt.options.typescript.nodeTsConfig.include ??= []
725
+ nuxt.options.typescript.nodeTsConfig.include.push(resolve('./augments.d.ts'))
726
+
727
+ // extend tsconfig.server.json
728
+ nuxt.options.nitro.typescript ??= {}
729
+ nuxt.options.nitro.typescript.tsConfig ??= {}
730
+ nuxt.options.nitro.typescript.tsConfig.include ??= []
731
+ nuxt.options.nitro.typescript.tsConfig.include.push(resolve('./augments.d.ts'))
732
+ ```
733
+
734
+ Alternatively, you can use the `prepare:types` and `nitro:prepare:types` hooks to extend the TypeScript references for specific type contexts, or modify the TypeScript configuration similar to the example above.
735
+
736
+ ```ts
737
+ nuxt.hook('prepare:types', ({ references, sharedReferences, nodeReferences }) => {
738
+ // extend app context
739
+ references.push({ path: resolve('./augments.d.ts') })
740
+ // extend shared context
741
+ sharedReferences.push({ path: resolve('./augments.d.ts') })
742
+ // extend node context
743
+ nodeReferences.push({ path: resolve('./augments.d.ts') })
744
+ })
745
+
746
+ nuxt.hook('nitro:prepare:types', ({ references }) => {
747
+ // extend server context
748
+ references.push({ path: resolve('./augments.d.ts') })
704
749
  })
705
750
  ```
706
751
 
752
+ ::note
753
+ TypeScript references add files to the type context [without being affected by the `exclude` option in `tsconfig.json`](https://www.typescriptlang.org/tsconfig/#exclude).
754
+ ::
755
+
756
+ #### Augmenting Types From Modules
757
+
758
+ Nuxt automatically includes your module's directories in the appropriate type contexts. To augment types from your module, all you need to do is place the type declaration file in the appropriate directory based on the augmented type context. Alternatively, you can [extend the TypeScript configuration](/docs/4.x/guide/going-further/modules#extending-tsconfigjson) to augment from an arbitrary location.
759
+
760
+ - `my-module/runtime/` - app type context (except for the `runtime/server` directory)
761
+ - `my-module/runtime/server/` - server type context
762
+ - `my-module/` - node type context (except for the `runtime/` and `runtime/server` directories)
763
+
764
+ ```bash [Directory Structure]
765
+ -| my-module/ # node type context
766
+ ---| runtime/ # app type context
767
+ ------| augments.app.d.ts
768
+ ------| server/ # server type context
769
+ ---------| augments.server.d.ts
770
+ ---| module.ts
771
+ ---| augments.node.d.ts
772
+ ```
773
+
707
774
  ### Testing
708
775
 
709
776
  Testing helps ensuring your module works as expected given various setup. Find in this section how to perform various kinds of tests against your module.
@@ -774,7 +841,7 @@ An example of such a workflow is available on [the module starter](https://githu
774
841
 
775
842
  Having a playground Nuxt application to test your module when developing it is really useful. [The module starter integrates one for that purpose](/docs/4.x/guide/going-further/modules#how-to-develop).
776
843
 
777
- You can test your module with other Nuxt applications (applications that are not part of your module repository) locally. To do so, you can use [`npm pack`](https://docs.npmjs.com/cli/commands/npm-pack) command, or your package manager equivalent, to create a tarball from your module. Then in your test project, you can add your module to `package.json` packages as: `"my-module": "file:/path/to/tarball.tgz"`.
844
+ You can test your module with other Nuxt applications (applications that are not part of your module repository) locally. To do so, you can use [`npm pack`](https://docs.npmjs.com/cli/commands/npm-pack/) command, or your package manager equivalent, to create a tarball from your module. Then in your test project, you can add your module to `package.json` packages as: `"my-module": "file:/path/to/tarball.tgz"`.
778
845
 
779
846
  After that, you should be able to reference `my-module` like in any regular project.
780
847
 
@@ -876,7 +943,7 @@ Watch Vue School video about Nuxt module types.
876
943
 
877
944
  ### Module Types
878
945
 
879
- **Official modules** are modules prefixed (scoped) with `@nuxt/` (e.g. [`@nuxt/content`](https://content.nuxtjs.org)). They are made and maintained actively by the Nuxt team. Like with the framework, contributions from the community are more than welcome to help make them better!
946
+ **Official modules** are modules prefixed (scoped) with `@nuxt/` (e.g. [`@nuxt/content`](https://content.nuxt.com)). They are made and maintained actively by the Nuxt team. Like with the framework, contributions from the community are more than welcome to help make them better!
880
947
 
881
948
  **Community modules** are modules prefixed (scoped) with `@nuxtjs/` (e.g. [`@nuxtjs/tailwindcss`](https://tailwindcss.nuxtjs.org)). They are proven modules made and maintained by community members. Again, contributions are welcome from anyone.
882
949
 
@@ -9,7 +9,7 @@ links:
9
9
 
10
10
  In Nuxt, you can access runtime app context within composables, components and plugins.
11
11
 
12
- ::read-more{to="https://v2.nuxt.com/docs/internals-glossary/context#the-context" target="_blank"}
12
+ ::read-more{to="https://v2.nuxt.com/docs/internals-glossary/context/#the-context" target="_blank"}
13
13
  In Nuxt 2, this was referred to as **Nuxt context**.
14
14
  ::
15
15
 
@@ -23,7 +23,7 @@ Jump over the `NuxtApp` interface documentation.
23
23
 
24
24
  Many composables and utilities, both built-in and user-made, may require access to the Nuxt instance. This doesn't exist everywhere on your application, because a fresh instance is created on every request.
25
25
 
26
- Currently, the Nuxt context is only accessible in [plugins](/docs/4.x/guide/directory-structure/plugins), [Nuxt hooks](/docs/4.x/guide/going-further/hooks), [Nuxt middleware](/docs/4.x/guide/directory-structure/app/middleware) (if wrapped in `defineNuxtRouteMiddleware`), and [setup functions](https://vuejs.org/api/composition-api-setup.html) (in pages and components).
26
+ Currently, the Nuxt context is only accessible in [plugins](/docs/4.x/guide/directory-structure/app/plugins), [Nuxt hooks](/docs/4.x/guide/going-further/hooks), [Nuxt middleware](/docs/4.x/guide/directory-structure/app/middleware) (if wrapped in `defineNuxtRouteMiddleware`), and [setup functions](https://vuejs.org/api/composition-api-setup) (in pages and components).
27
27
 
28
28
  If a composable is called without access to the context, you may get an error stating that 'A composable that requires access to the Nuxt instance was called outside of a plugin, Nuxt hook, Nuxt middleware, or Vue setup function.' In that case, you can also explicitly call functions within this context by using [`nuxtApp.runWithContext`](/docs/4.x/api/composables/use-nuxt-app#runwithcontext).
29
29
 
@@ -42,7 +42,7 @@ If your composable does not always need `nuxtApp` or you simply want to check if
42
42
 
43
43
  Plugins also receive `nuxtApp` as the first argument for convenience.
44
44
 
45
- :read-more{to="/docs/4.x/guide/directory-structure/plugins"}
45
+ :read-more{to="/docs/4.x/guide/directory-structure/app/plugins"}
46
46
 
47
47
  ## Providing Helpers
48
48
 
@@ -55,10 +55,10 @@ nuxtApp.provide('hello', name => `Hello ${name}!`)
55
55
  console.log(nuxtApp.$hello('name')) // Prints "Hello name!"
56
56
  ```
57
57
 
58
- ::read-more{to="/docs/4.x/guide/directory-structure/plugins#providing-helpers"}
58
+ ::read-more{to="/docs/4.x/guide/directory-structure/app/plugins#providing-helpers"}
59
59
  It is possible to inject helpers by returning an object with a `provide` key in plugins.
60
60
  ::
61
61
 
62
- ::read-more{to="https://v2.nuxt.com/docs/directory-structure/plugins#inject-in-root--context" target="_blank"}
62
+ ::read-more{to="https://v2.nuxt.com/docs/directory-structure/plugins/#inject-in-root--context" target="_blank"}
63
63
  In Nuxt 2 plugins, this was referred to as **inject function**.
64
64
  ::
@@ -20,9 +20,9 @@ Additionally, certain other files in the layer directory will be auto-scanned an
20
20
  - [`app/layouts/*`](/docs/4.x/guide/directory-structure/app/layouts) - Extend the default layouts
21
21
  - [`app/middleware/*`](/docs/4.x/guide/directory-structure/app/middleware) - Extend the default middleware
22
22
  - [`app/pages/*`](/docs/4.x/guide/directory-structure/app/pages) - Extend the default pages
23
- - [`app/plugins/*`](/docs/4.x/guide/directory-structure/plugins) - Extend the default plugins
23
+ - [`app/plugins/*`](/docs/4.x/guide/directory-structure/app/plugins) - Extend the default plugins
24
24
  - [`app/utils/*`](/docs/4.x/guide/directory-structure/app/utils) - Extend the default utils
25
- - [`app/app.config.ts`](/docs/4.x/guide/directory-structure/app-config) - Extend the default app config
25
+ - [`app/app.config.ts`](/docs/4.x/guide/directory-structure/app/app-config) - Extend the default app config
26
26
  - [`server/*`](/docs/4.x/guide/directory-structure/server) - Extend the default server endpoints & middleware
27
27
  - [`nuxt.config.ts`](/docs/4.x/guide/directory-structure/nuxt-config)- Extend the default nuxt config
28
28
 
@@ -68,29 +68,46 @@ Additionally, certain other files in the layer directory will be auto-scanned an
68
68
 
69
69
  ## Layer Priority
70
70
 
71
- When extending from multiple layers, it's important to understand the priority order:
71
+ When extending from multiple layers, it's important to understand the override order. Layers with **higher priority** override layers with lower priority when they define the same files or components.
72
72
 
73
- 1. **Layers in `extends`** - earlier entries have higher priority (first overrides second)
74
- 2. **Auto-scanned local layers** from `~~/layers` directory in alphabetical order (Z overrides A)
75
- 3. **Your project** has the highest priority in the stack - it will always override other layers
73
+ The priority order from highest to lowest is:
76
74
 
77
- For example:
75
+ 1. **Your project files** - always have the highest priority
76
+ 2. **Auto-scanned layers** from `~~/layers` directory - sorted alphabetically (Z has higher priority than A)
77
+ 3. **Layers in `extends`** config - first entry has higher priority than second
78
+
79
+ ### When to Use Each
80
+
81
+ - **`extends`** - Use for external dependencies (npm packages, remote repositories) or layers outside your project directory
82
+ - **`~~/layers` directory** - Use for local layers that are part of your project
83
+
84
+ ::tip
85
+ If you need to control the order of auto-scanned layers, you can prefix them with numbers: `~/layers/1.z-layer`, `~/layers/2.a-layer`. This way `2.a-layer` will have higher priority than `1.z-layer`.
86
+ ::
87
+
88
+ ### Example
78
89
 
79
90
  ```ts [nuxt.config.ts]
80
91
  export default defineNuxtConfig({
81
92
  extends: [
82
- // Highest priority (among extends)
83
- './layers/base',
84
- // Medium priority
85
- './layers/theme',
86
- // Lower priority
87
- './layers/custom',
93
+ // Local layer outside the project
94
+ '../base',
95
+ // NPM package
96
+ '@my-themes/awesome',
97
+ // Remote repository
98
+ 'github:my-themes/awesome#v1',
88
99
  ],
89
- // Your project has the highest priority
90
100
  })
91
101
  ```
92
102
 
93
- If you also have auto-scanned layers like `~~/layers/a` and `~~/layers/z`, the complete override order would be: `base` > `theme` > `custom` > `z` > `a` > your project.
103
+ If you also have `~~/layers/custom`, the priority order is:
104
+ - Your project files (highest)
105
+ - `~~/layers/custom`
106
+ - `../base`
107
+ - `@my-themes/awesome`
108
+ - `github:my-themes/awesome#v1` (lowest)
109
+
110
+ This means your project files will override any layer, and `~~/layers/custom` will override anything in `extends`.
94
111
 
95
112
  ## Starter Template
96
113
 
@@ -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://go.microsoft.com/fwlink/?linkid=830387).
39
+ You may need to update the config below with a path to your web browser. For more information, visit the [VS Code documentation about debug configuration](https://code.visualstudio.com/docs/debugtest/debugging#_launch-configurations).
40
40
 
41
41
  ```json5
42
42
  {
@@ -17,7 +17,7 @@ If it returns `null` or `undefined`, Nuxt will fall back to the default routes (
17
17
  import type { RouterConfig } from '@nuxt/schema'
18
18
 
19
19
  export default {
20
- // https://router.vuejs.org/api/interfaces/routeroptions.html#routes
20
+ // https://router.vuejs.org/api/interfaces/routeroptions#routes
21
21
  routes: _routes => [
22
22
  {
23
23
  name: 'home',
@@ -81,13 +81,13 @@ The [Nuxt kit](/docs/4.x/guide/going-further/kit) provides a few ways [to add ro
81
81
 
82
82
  ## Router Options
83
83
 
84
- On top of customizing options for [`vue-router`](https://router.vuejs.org/api/interfaces/routeroptions.html), Nuxt offers [additional options](/docs/4.x/api/nuxt-config#router) to customize the router.
84
+ On top of customizing options for [`vue-router`](https://router.vuejs.org/api/interfaces/routeroptions), Nuxt offers [additional options](/docs/4.x/api/nuxt-config#router) to customize the router.
85
85
 
86
86
  ### Using `router.options`
87
87
 
88
88
  This is the recommended way to specify [router options](/docs/4.x/api/nuxt-config#router).
89
89
 
90
- ```ts [router.options.ts]
90
+ ```ts [app/router.options.ts]
91
91
  import type { RouterConfig } from '@nuxt/schema'
92
92
 
93
93
  export default {
@@ -175,7 +175,7 @@ import type { RouterConfig } from '@nuxt/schema'
175
175
  import { createMemoryHistory } from 'vue-router'
176
176
 
177
177
  export default {
178
- // https://router.vuejs.org/api/interfaces/routeroptions.html
178
+ // https://router.vuejs.org/api/interfaces/routeroptions
179
179
  history: base => import.meta.client ? createMemoryHistory(base) : null, /* default */
180
180
  } satisfies RouterConfig
181
181
  ```
@@ -12,7 +12,7 @@ However, Nuxt provides a way to create a custom fetcher for your API (or multipl
12
12
 
13
13
  ## Custom `$fetch`
14
14
 
15
- Let's create a custom `$fetch` instance with a [Nuxt plugin](/docs/4.x/guide/directory-structure/plugins).
15
+ Let's create a custom `$fetch` instance with a [Nuxt plugin](/docs/4.x/guide/directory-structure/app/plugins).
16
16
 
17
17
  ::note
18
18
  `$fetch` is a configured instance of [ofetch](https://github.com/unjs/ofetch) which supports adding the base URL of your Nuxt server as well as direct function calls during SSR (avoiding HTTP roundtrips).
@@ -184,5 +184,5 @@ onMounted(() => {
184
184
  4. **Avoid side effects in setup**: Move browser-dependent code to `onMounted`
185
185
 
186
186
  ::tip
187
- You can read the [Vue documentation on SSR hydration mismatch](https://vuejs.org/guide/scaling-up/ssr.html#hydration-mismatch) for a better understanding of hydration.
187
+ You can read the [Vue documentation on SSR hydration mismatch](https://vuejs.org/guide/scaling-up/ssr#hydration-mismatch) for a better understanding of hydration.
188
188
  ::
@@ -12,7 +12,7 @@ links:
12
12
 
13
13
  Usage of `<NuxtPicture>` is almost identical to [`<NuxtImg>`](/docs/4.x/api/components/nuxt-img) but it also allows serving modern formats like `webp` when possible.
14
14
 
15
- Learn more about the [`<picture>` tag on MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture).
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.html) 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.
7
+ The `to` target of [`<Teleport>`](https://vuejs.org/guide/built-ins/teleport) expects a CSS selector string or an actual DOM node. Nuxt currently has SSR support for teleports to `#teleports` only, with client-side support for other targets using a `<ClientOnly>` wrapper.
8
8
  ::
9
9
 
10
10
  ## Body Teleport
@@ -16,7 +16,7 @@ This component is available in Nuxt v3.12+.
16
16
 
17
17
  ## Usage
18
18
 
19
- Add `<NuxtRouteAnnouncer/>` in your [`app.vue`](/docs/4.x/guide/directory-structure/app) or [`app/layouts/`](/docs/4.x/guide/directory-structure/app/layouts) to enhance accessibility by informing assistive technologies about page title changes. This ensures that navigational changes are announced to users relying on screen readers.
19
+ Add `<NuxtRouteAnnouncer/>` in your [`app.vue`](/docs/4.x/guide/directory-structure/app/app) or [`app/layouts/`](/docs/4.x/guide/directory-structure/app/layouts) to enhance accessibility by informing assistive technologies about page title changes. This ensures that navigational changes are announced to users relying on screen readers.
20
20
 
21
21
  ```vue [app/app.vue]
22
22
  <template>
@@ -11,7 +11,7 @@ links:
11
11
  `<NuxtPage>` is a built-in component that comes with Nuxt. It lets you display top-level or nested pages located in the [`app/pages/`](/docs/4.x/guide/directory-structure/app/pages) directory.
12
12
 
13
13
  ::note
14
- `<NuxtPage>` is a wrapper around [`<RouterView>`](https://router.vuejs.org/api/interfaces/RouterViewProps.html#interface-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.
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:
@@ -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/RouterLinkProps.html)
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/RouteLocation.html) 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.html#Properties-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.html#Properties-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.html#Properties-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.html#Properties-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.html#Properties-ariaCurrentValue) on internal links
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/api/nuxt-config#crossoriginprefetch)) of links in the viewport. Used by the experimental [crossOriginPrefetch](/docs/4.x/api/nuxt-config#crossoriginprefetch) config.
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/api/nuxt-config#defaults)
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/RouterOptions.html#Properties-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.html#Properties-linkExactActiveClass). Defaults to Vue Router's default (`"router-link-exact-active"`)
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.html#onerrorcaptured) hook under the hood.
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
@@ -16,4 +16,4 @@ const appConfig = useAppConfig()
16
16
  console.log(appConfig)
17
17
  ```
18
18
 
19
- :read-more{to="/docs/4.x/guide/directory-structure/app-config"}
19
+ :read-more{to="/docs/4.x/guide/directory-structure/app/app-config"}
@@ -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 `status` refs. This ensures consistency across components but requires option consistency.
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,14 +230,16 @@ 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: (nuxtApp: NuxtApp, options: { signal: AbortSignal }) => Promise<DataT>,
175
- options?: AsyncDataOptions<DataT>
236
+ handler: AsyncDataHandler<DataT>,
237
+ options?: AsyncDataOptions<DataT>,
176
238
  ): AsyncData<DataT, DataE>
177
239
  export function useAsyncData<DataT, DataE> (
178
240
  key: MaybeRefOrGetter<string>,
179
- handler: (nuxtApp: NuxtApp, options: { signal: AbortSignal }) => Promise<DataT>,
180
- options?: AsyncDataOptions<DataT>
241
+ handler: AsyncDataHandler<DataT>,
242
+ options?: AsyncDataOptions<DataT>,
181
243
  ): Promise<AsyncData<DataT, DataE>>
182
244
 
183
245
  type AsyncDataOptions<DataT> = {
@@ -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 {
@@ -42,7 +42,7 @@ export interface CookieRef<T> extends Ref<T> {}
42
42
 
43
43
  export function useCookie<T = string | null | undefined> (
44
44
  name: string,
45
- options?: CookieOptions<T>
45
+ options?: CookieOptions<T>,
46
46
  ): CookieRef<T>
47
47
  ```
48
48
 
@@ -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://tools.ietf.org/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://tools.ietf.org/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. |
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://tools.ietf.org/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. |
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://tools.ietf.org/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://tools.ietf.org/html/rfc6265#section-5.2.4). By default, the path is considered the ["default path"](https://tools.ietf.org/html/rfc6265#section-5.1.4). |
71
- | `sameSite` | `boolean \| string` | `undefined` | Sets the [`SameSite` `Set-Cookie` attribute](https://tools.ietf.org/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. |
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