@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.
- package/1.getting-started/02.installation.md +3 -3
- package/1.getting-started/03.configuration.md +4 -4
- package/1.getting-started/04.views.md +2 -2
- package/1.getting-started/05.assets.md +1 -1
- package/1.getting-started/06.styling.md +11 -11
- package/1.getting-started/07.routing.md +4 -0
- package/1.getting-started/09.transitions.md +6 -6
- package/1.getting-started/10.data-fetching.md +14 -14
- package/1.getting-started/11.state-management.md +2 -2
- package/1.getting-started/12.error-handling.md +4 -4
- package/1.getting-started/13.server.md +4 -4
- package/1.getting-started/14.layers.md +29 -10
- package/1.getting-started/17.testing.md +3 -3
- package/1.getting-started/18.upgrade.md +19 -11
- package/2.guide/1.directory-structure/1.app/1.components.md +4 -4
- package/2.guide/1.directory-structure/1.app/1.composables.md +1 -1
- package/2.guide/1.directory-structure/1.app/1.layouts.md +2 -2
- package/2.guide/1.directory-structure/1.app/1.middleware.md +4 -4
- package/2.guide/1.directory-structure/1.app/1.pages.md +13 -13
- package/2.guide/1.directory-structure/1.app/1.plugins.md +1 -5
- package/2.guide/1.directory-structure/1.node_modules.md +1 -1
- package/2.guide/1.directory-structure/1.public.md +1 -1
- package/2.guide/1.directory-structure/1.server.md +5 -5
- package/2.guide/1.directory-structure/2.env.md +1 -1
- package/2.guide/1.directory-structure/3.tsconfig.md +38 -7
- package/2.guide/2.concepts/1.auto-imports.md +2 -2
- package/2.guide/2.concepts/10.nuxt-lifecycle.md +3 -3
- package/2.guide/2.concepts/2.vuejs-development.md +3 -3
- package/2.guide/2.concepts/3.rendering.md +4 -4
- package/2.guide/2.concepts/7.esm.md +2 -2
- package/2.guide/2.concepts/8.typescript.md +15 -38
- package/2.guide/2.concepts/9.code-style.md +1 -1
- package/2.guide/3.going-further/1.experimental-features.md +6 -6
- package/2.guide/3.going-further/1.features.md +1 -1
- package/2.guide/3.going-further/1.internals.md +2 -2
- package/2.guide/3.going-further/2.hooks.md +1 -1
- package/2.guide/3.going-further/3.modules.md +77 -10
- package/2.guide/3.going-further/6.nuxt-app.md +5 -5
- package/2.guide/3.going-further/7.layers.md +32 -15
- package/2.guide/3.going-further/9.debugging.md +1 -1
- package/2.guide/4.recipes/1.custom-routing.md +4 -4
- package/2.guide/4.recipes/3.custom-usefetch.md +1 -1
- package/2.guide/5.best-practices/hydration.md +1 -1
- package/3.api/1.components/10.nuxt-picture.md +1 -1
- package/3.api/1.components/11.teleports.md +1 -1
- package/3.api/1.components/12.nuxt-route-announcer.md +1 -1
- package/3.api/1.components/2.nuxt-page.md +1 -1
- package/3.api/1.components/4.nuxt-link.md +11 -11
- package/3.api/1.components/5.nuxt-loading-indicator.md +1 -1
- package/3.api/1.components/6.nuxt-error-boundary.md +1 -1
- package/3.api/2.composables/use-app-config.md +1 -1
- package/3.api/2.composables/use-async-data.md +76 -13
- package/3.api/2.composables/use-cookie.md +7 -7
- package/3.api/2.composables/use-fetch.md +2 -2
- package/3.api/2.composables/use-head-safe.md +37 -20
- package/3.api/2.composables/use-head.md +136 -36
- package/3.api/2.composables/use-hydration.md +24 -18
- package/3.api/2.composables/use-lazy-async-data.md +58 -9
- package/3.api/2.composables/use-lazy-fetch.md +65 -9
- package/3.api/2.composables/use-nuxt-app.md +7 -7
- package/3.api/2.composables/use-nuxt-data.md +1 -1
- package/3.api/2.composables/use-request-fetch.md +1 -1
- package/3.api/2.composables/use-route.md +1 -1
- package/3.api/2.composables/use-router.md +15 -15
- package/3.api/2.composables/use-runtime-hook.md +1 -1
- package/3.api/2.composables/use-state.md +1 -1
- package/3.api/3.utils/abort-navigation.md +2 -2
- package/3.api/3.utils/define-lazy-hydration-component.md +4 -4
- package/3.api/3.utils/define-nuxt-component.md +1 -1
- package/3.api/3.utils/define-nuxt-plugin.md +1 -1
- package/3.api/3.utils/define-nuxt-route-middleware.md +1 -1
- package/3.api/3.utils/define-page-meta.md +8 -8
- package/3.api/3.utils/navigate-to.md +5 -5
- package/3.api/3.utils/on-before-route-leave.md +1 -1
- package/3.api/3.utils/on-before-route-update.md +1 -1
- package/3.api/3.utils/refresh-cookie.md +1 -1
- package/3.api/3.utils/update-app-config.md +2 -2
- package/3.api/5.kit/1.modules.md +3 -3
- package/3.api/5.kit/14.builder.md +6 -6
- package/3.api/5.kit/2.programmatic.md +2 -2
- package/3.api/6.advanced/1.hooks.md +5 -5
- package/3.api/6.nuxt-config.md +25 -25
- package/5.community/3.reporting-bugs.md +1 -1
- package/5.community/4.contribution.md +1 -1
- package/5.community/5.framework-contribution.md +8 -8
- package/5.community/6.roadmap.md +3 -3
- package/6.bridge/4.plugins-and-middleware.md +1 -1
- package/7.migration/2.configuration.md +2 -2
- package/7.migration/20.module-authors.md +1 -1
- package/7.migration/5.plugins-and-middleware.md +1 -1
- package/7.migration/6.pages-and-layouts.md +2 -2
- package/README.md +1 -1
- package/package.json +1 -1
|
@@ -26,17 +26,17 @@ If you only need the router instance within your template, use `$router`:
|
|
|
26
26
|
|
|
27
27
|
If you have a `app/pages/` directory, `useRouter` is identical in behavior to the one provided by `vue-router`.
|
|
28
28
|
|
|
29
|
-
::read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/interfaces/
|
|
29
|
+
::read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/interfaces/router#Properties-currentRoute-" target="_blank"}
|
|
30
30
|
Read `vue-router` documentation about the `Router` interface.
|
|
31
31
|
::
|
|
32
32
|
|
|
33
33
|
## Basic Manipulation
|
|
34
34
|
|
|
35
|
-
- [`addRoute()`](https://router.vuejs.org/api/interfaces/
|
|
36
|
-
- [`removeRoute()`](https://router.vuejs.org/api/interfaces/
|
|
37
|
-
- [`getRoutes()`](https://router.vuejs.org/api/interfaces/
|
|
38
|
-
- [`hasRoute()`](https://router.vuejs.org/api/interfaces/
|
|
39
|
-
- [`resolve()`](https://router.vuejs.org/api/interfaces/
|
|
35
|
+
- [`addRoute()`](https://router.vuejs.org/api/interfaces/router#addRoute-): Add a new route to the router instance. `parentName` can be provided to add new route as the child of an existing route.
|
|
36
|
+
- [`removeRoute()`](https://router.vuejs.org/api/interfaces/router#removeRoute-): Remove an existing route by its name.
|
|
37
|
+
- [`getRoutes()`](https://router.vuejs.org/api/interfaces/router#getRoutes-): Get a full list of all the route records.
|
|
38
|
+
- [`hasRoute()`](https://router.vuejs.org/api/interfaces/router#hasRoute-): Checks if a route with a given name exists.
|
|
39
|
+
- [`resolve()`](https://router.vuejs.org/api/interfaces/router#resolve-): Returns the normalized version of a route location. Also includes an `href` property that includes any existing base.
|
|
40
40
|
|
|
41
41
|
```ts [Example]
|
|
42
42
|
const router = useRouter()
|
|
@@ -49,16 +49,16 @@ router.resolve({ name: 'home' })
|
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
::note
|
|
52
|
-
`router.addRoute()` adds route details into an array of routes and it is useful while building [Nuxt plugins](/docs/4.x/guide/directory-structure/plugins) while `router.push()` on the other hand, triggers a new navigation immediately and it is useful in pages, Vue components and composable.
|
|
52
|
+
`router.addRoute()` adds route details into an array of routes and it is useful while building [Nuxt plugins](/docs/4.x/guide/directory-structure/app/plugins) while `router.push()` on the other hand, triggers a new navigation immediately and it is useful in pages, Vue components and composable.
|
|
53
53
|
::
|
|
54
54
|
|
|
55
55
|
## Based on History API
|
|
56
56
|
|
|
57
|
-
- [`back()`](https://router.vuejs.org/api/interfaces/
|
|
58
|
-
- [`forward()`](https://router.vuejs.org/api/interfaces/
|
|
59
|
-
- [`go()`](https://router.vuejs.org/api/interfaces/
|
|
60
|
-
- [`push()`](https://router.vuejs.org/api/interfaces/
|
|
61
|
-
- [`replace()`](https://router.vuejs.org/api/interfaces/
|
|
57
|
+
- [`back()`](https://router.vuejs.org/api/interfaces/router#back-): Go back in history if possible, same as `router.go(-1)`.
|
|
58
|
+
- [`forward()`](https://router.vuejs.org/api/interfaces/router#forward-): Go forward in history if possible, same as `router.go(1)`.
|
|
59
|
+
- [`go()`](https://router.vuejs.org/api/interfaces/router#go-): Move forward or backward through the history without the hierarchical restrictions enforced in `router.back()` and `router.forward()`.
|
|
60
|
+
- [`push()`](https://router.vuejs.org/api/interfaces/router#push-): Programmatically navigate to a new URL by pushing an entry in the history stack. **It is recommended to use [`navigateTo`](/docs/4.x/api/utils/navigate-to) instead.**
|
|
61
|
+
- [`replace()`](https://router.vuejs.org/api/interfaces/router#replace-): Programmatically navigate to a new URL by replacing the current entry in the routes history stack. **It is recommended to use [`navigateTo`](/docs/4.x/api/utils/navigate-to) instead.**
|
|
62
62
|
|
|
63
63
|
```ts [Example]
|
|
64
64
|
const router = useRouter()
|
|
@@ -84,10 +84,10 @@ However, Nuxt has a concept of **route middleware** that simplifies the implemen
|
|
|
84
84
|
|
|
85
85
|
## Promise and Error Handling
|
|
86
86
|
|
|
87
|
-
- [`isReady()`](https://router.vuejs.org/api/interfaces/
|
|
88
|
-
- [`onError`](https://router.vuejs.org/api/interfaces/
|
|
87
|
+
- [`isReady()`](https://router.vuejs.org/api/interfaces/router#isReady-): Returns a Promise that resolves when the router has completed the initial navigation.
|
|
88
|
+
- [`onError`](https://router.vuejs.org/api/interfaces/router#onError-): Adds an error handler that is called every time a non caught error happens during navigation.
|
|
89
89
|
|
|
90
|
-
:read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/interfaces/
|
|
90
|
+
:read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/interfaces/router#Methods-" title="Vue Router Docs" target="_blank"}
|
|
91
91
|
|
|
92
92
|
## Universal Router Instance
|
|
93
93
|
|
|
@@ -15,7 +15,7 @@ This composable is available in Nuxt v3.14+.
|
|
|
15
15
|
```ts [signature]
|
|
16
16
|
function useRuntimeHook<THookName extends keyof RuntimeNuxtHooks> (
|
|
17
17
|
name: THookName,
|
|
18
|
-
fn: RuntimeNuxtHooks[THookName] extends HookCallback ? RuntimeNuxtHooks[THookName] : never
|
|
18
|
+
fn: RuntimeNuxtHooks[THookName] extends HookCallback ? RuntimeNuxtHooks[THookName] : never,
|
|
19
19
|
): void
|
|
20
20
|
```
|
|
21
21
|
|
|
@@ -29,7 +29,7 @@ Because the data inside `useState` will be serialized to JSON, it is important t
|
|
|
29
29
|
|
|
30
30
|
## Using `shallowRef`
|
|
31
31
|
|
|
32
|
-
If you don't need your state to be deeply reactive, you can combine `useState` with [`shallowRef`](https://vuejs.org/api/reactivity-advanced
|
|
32
|
+
If you don't need your state to be deeply reactive, you can combine `useState` with [`shallowRef`](https://vuejs.org/api/reactivity-advanced#shallowref). This can improve performance when your state contains large objects and arrays.
|
|
33
33
|
|
|
34
34
|
```ts
|
|
35
35
|
const state = useState('my-shallow-state', () => shallowRef({ deep: 'not reactive' }))
|
|
@@ -22,7 +22,7 @@ export function abortNavigation (err?: Error | string): false
|
|
|
22
22
|
|
|
23
23
|
### `err`
|
|
24
24
|
|
|
25
|
-
- **Type**: [`Error`](https://developer.mozilla.org/
|
|
25
|
+
- **Type**: [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) | `string`
|
|
26
26
|
|
|
27
27
|
Optional error to be thrown by `abortNavigation`.
|
|
28
28
|
|
|
@@ -60,7 +60,7 @@ export default defineNuxtRouteMiddleware((to, from) => {
|
|
|
60
60
|
|
|
61
61
|
### `err` as an Error Object
|
|
62
62
|
|
|
63
|
-
You can pass the error as an [`Error`](https://developer.mozilla.org/
|
|
63
|
+
You can pass the error as an [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object, e.g. caught by the `catch`-block:
|
|
64
64
|
|
|
65
65
|
```ts [app/middleware/auth.ts]
|
|
66
66
|
export default defineNuxtRouteMiddleware((to, from) => {
|
|
@@ -42,7 +42,7 @@ Read more about the options for `hydrate-on-visible`.
|
|
|
42
42
|
::
|
|
43
43
|
|
|
44
44
|
::note
|
|
45
|
-
Under the hood, this uses Vue's built-in [`hydrateOnVisible` strategy](https://vuejs.org/guide/components/async
|
|
45
|
+
Under the hood, this uses Vue's built-in [`hydrateOnVisible` strategy](https://vuejs.org/guide/components/async#hydrate-on-visible).
|
|
46
46
|
::
|
|
47
47
|
|
|
48
48
|
### Idle Strategy
|
|
@@ -70,7 +70,7 @@ The `hydrateOnIdle` prop is optional. You can pass a positive number to specify
|
|
|
70
70
|
Idle strategy is for components that can be hydrated when the browser is idle.
|
|
71
71
|
|
|
72
72
|
::note
|
|
73
|
-
Under the hood, this uses Vue's built-in [`hydrateOnIdle` strategy](https://vuejs.org/guide/components/async
|
|
73
|
+
Under the hood, this uses Vue's built-in [`hydrateOnIdle` strategy](https://vuejs.org/guide/components/async#hydrate-on-idle).
|
|
74
74
|
::
|
|
75
75
|
|
|
76
76
|
### Interaction Strategy
|
|
@@ -99,7 +99,7 @@ const LazyHydrationMyComponent = defineLazyHydrationComponent(
|
|
|
99
99
|
The `hydrateOnInteraction` prop is optional. If you do not pass an event or a list of events, it defaults to hydrating on `pointerenter`, `click`, and `focus`.
|
|
100
100
|
|
|
101
101
|
::note
|
|
102
|
-
Under the hood, this uses Vue's built-in [`hydrateOnInteraction` strategy](https://vuejs.org/guide/components/async
|
|
102
|
+
Under the hood, this uses Vue's built-in [`hydrateOnInteraction` strategy](https://vuejs.org/guide/components/async#hydrate-on-interaction).
|
|
103
103
|
::
|
|
104
104
|
|
|
105
105
|
### Media Query Strategy
|
|
@@ -126,7 +126,7 @@ const LazyHydrationMyComponent = defineLazyHydrationComponent(
|
|
|
126
126
|
```
|
|
127
127
|
|
|
128
128
|
::note
|
|
129
|
-
Under the hood, this uses Vue's built-in [`hydrateOnMediaQuery` strategy](https://vuejs.org/guide/components/async
|
|
129
|
+
Under the hood, this uses Vue's built-in [`hydrateOnMediaQuery` strategy](https://vuejs.org/guide/components/async#hydrate-on-media-query).
|
|
130
130
|
::
|
|
131
131
|
|
|
132
132
|
### Time Strategy
|
|
@@ -9,7 +9,7 @@ links:
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
::note
|
|
12
|
-
`defineNuxtComponent()` is a helper function for defining type safe Vue components using options API similar to [`defineComponent()`](https://vuejs.org/api/general
|
|
12
|
+
`defineNuxtComponent()` is a helper function for defining type safe Vue components using options API similar to [`defineComponent()`](https://vuejs.org/api/general#definecomponent). `defineNuxtComponent()` wrapper also adds support for `asyncData` and `head` component options.
|
|
13
13
|
::
|
|
14
14
|
|
|
15
15
|
::note
|
|
@@ -42,7 +42,7 @@ interface ObjectPlugin<T> {
|
|
|
42
42
|
## Parameters
|
|
43
43
|
|
|
44
44
|
**plugin**: A plugin can be defined in two ways:
|
|
45
|
-
1. **Function Plugin**: A function that receives the [`NuxtApp`](/docs/4.x/guide/going-further/internals#the-nuxtapp-interface) instance and can return a promise with
|
|
45
|
+
1. **Function Plugin**: A function that receives the [`NuxtApp`](/docs/4.x/guide/going-further/internals#the-nuxtapp-interface) instance and can return a promise with a potential object with a [`provide`](/docs/4.x/guide/directory-structure/app/plugins#providing-helpers) property if you want to provide a helper on [`NuxtApp`](/docs/4.x/guide/going-further/internals#the-nuxtapp-interface) instance.
|
|
46
46
|
2. **Object Plugin**: An object that can include various properties to configure the plugin's behavior, such as `name`, `enforce`, `dependsOn`, `order`, `parallel`, `setup`, `hooks`, and `env`.
|
|
47
47
|
|
|
48
48
|
| Property | Type | Required | Description |
|
|
@@ -28,7 +28,7 @@ interface RouteMiddleware {
|
|
|
28
28
|
|
|
29
29
|
A function that takes two Vue Router's route location objects as parameters: the next route `to` as the first, and the current route `from` as the second.
|
|
30
30
|
|
|
31
|
-
Learn more about available properties of `RouteLocationNormalized` in the **[Vue Router docs](https://router.vuejs.org/api/type-aliases/
|
|
31
|
+
Learn more about available properties of `RouteLocationNormalized` in the **[Vue Router docs](https://router.vuejs.org/api/type-aliases/routelocationnormalized)**.
|
|
32
32
|
|
|
33
33
|
## Examples
|
|
34
34
|
|
|
@@ -62,7 +62,7 @@ interface PageMeta {
|
|
|
62
62
|
|
|
63
63
|
- **Type**: `string`
|
|
64
64
|
|
|
65
|
-
You may define a [custom regular expression](/docs/4.x/api/
|
|
65
|
+
You may define a [custom regular expression](/docs/4.x/api/utils/define-page-meta#using-a-custom-regular-expression) if you have a more complex pattern than can be expressed with the file name.
|
|
66
66
|
|
|
67
67
|
**`props`**
|
|
68
68
|
|
|
@@ -78,9 +78,9 @@ interface PageMeta {
|
|
|
78
78
|
|
|
79
79
|
**`keepalive`**
|
|
80
80
|
|
|
81
|
-
- **Type**: `boolean` | [`KeepAliveProps`](https://vuejs.org/api/built-in-components
|
|
81
|
+
- **Type**: `boolean` | [`KeepAliveProps`](https://vuejs.org/api/built-in-components#keepalive)
|
|
82
82
|
|
|
83
|
-
Set to `true` when you want to preserve page state across route changes or use the [`KeepAliveProps`](https://vuejs.org/api/built-in-components
|
|
83
|
+
Set to `true` when you want to preserve page state across route changes or use the [`KeepAliveProps`](https://vuejs.org/api/built-in-components#keepalive) for a fine-grained control.
|
|
84
84
|
|
|
85
85
|
**`key`**
|
|
86
86
|
|
|
@@ -96,19 +96,19 @@ interface PageMeta {
|
|
|
96
96
|
|
|
97
97
|
**`layoutTransition`**
|
|
98
98
|
|
|
99
|
-
- **Type**: `boolean` | [`TransitionProps`](https://vuejs.org/api/built-in-components
|
|
99
|
+
- **Type**: `boolean` | [`TransitionProps`](https://vuejs.org/api/built-in-components#transition)
|
|
100
100
|
|
|
101
101
|
Set name of the transition to apply for current layout. You can also set this value to `false` to disable the layout transition.
|
|
102
102
|
|
|
103
103
|
**`middleware`**
|
|
104
104
|
|
|
105
|
-
- **Type**: `MiddlewareKey` | [`NavigationGuard`](https://router.vuejs.org/api/interfaces/
|
|
105
|
+
- **Type**: `MiddlewareKey` | [`NavigationGuard`](https://router.vuejs.org/api/interfaces/navigationguard) | `Array<MiddlewareKey | NavigationGuard>`
|
|
106
106
|
|
|
107
107
|
Define anonymous or named middleware directly within `definePageMeta`. Learn more about [route middleware](/docs/4.x/guide/directory-structure/app/middleware).
|
|
108
108
|
|
|
109
109
|
**`pageTransition`**
|
|
110
110
|
|
|
111
|
-
- **Type**: `boolean` | [`TransitionProps`](https://vuejs.org/api/built-in-components
|
|
111
|
+
- **Type**: `boolean` | [`TransitionProps`](https://vuejs.org/api/built-in-components#transition)
|
|
112
112
|
|
|
113
113
|
Set name of the transition to apply for current page. You can also set this value to `false` to disable the page transition.
|
|
114
114
|
|
|
@@ -122,7 +122,7 @@ interface PageMeta {
|
|
|
122
122
|
|
|
123
123
|
**`redirect`**
|
|
124
124
|
|
|
125
|
-
- **Type**: [`RouteRecordRedirectOption`](https://router.vuejs.org/guide/essentials/redirect-and-alias
|
|
125
|
+
- **Type**: [`RouteRecordRedirectOption`](https://router.vuejs.org/guide/essentials/redirect-and-alias)
|
|
126
126
|
|
|
127
127
|
Where to redirect if the route is directly matched. The redirection happens before any navigation guard and triggers a new navigation with the new target location.
|
|
128
128
|
|
|
@@ -215,7 +215,7 @@ definePageMeta({
|
|
|
215
215
|
</script>
|
|
216
216
|
```
|
|
217
217
|
|
|
218
|
-
For more examples see [Vue Router's Matching Syntax](https://router.vuejs.org/guide/essentials/route-matching-syntax
|
|
218
|
+
For more examples see [Vue Router's Matching Syntax](https://router.vuejs.org/guide/essentials/route-matching-syntax).
|
|
219
219
|
|
|
220
220
|
### Defining Layout
|
|
221
221
|
|
|
@@ -17,7 +17,7 @@ Make sure to always use `await` or `return` on result of `navigateTo` when calli
|
|
|
17
17
|
::
|
|
18
18
|
|
|
19
19
|
::note
|
|
20
|
-
`navigateTo` cannot be used within Nitro routes. To perform a server-side redirect in Nitro routes, use [`sendRedirect`](https://h3.dev/utils/response#
|
|
20
|
+
`navigateTo` cannot be used within Nitro routes. To perform a server-side redirect in Nitro routes, use [`sendRedirect`](https://h3.dev/utils/response#redirectlocation-status-statustext) instead.
|
|
21
21
|
::
|
|
22
22
|
|
|
23
23
|
### Within a Vue Component
|
|
@@ -119,7 +119,7 @@ await navigateTo('https://nuxt.com', {
|
|
|
119
119
|
```ts [Signature]
|
|
120
120
|
export function navigateTo (
|
|
121
121
|
to: RouteLocationRaw | undefined | null,
|
|
122
|
-
options?: NavigateToOptions
|
|
122
|
+
options?: NavigateToOptions,
|
|
123
123
|
): Promise<void | NavigationFailure | false> | false | void | RouteLocationRaw
|
|
124
124
|
|
|
125
125
|
interface NavigateToOptions {
|
|
@@ -148,7 +148,7 @@ type OpenWindowFeatures = {
|
|
|
148
148
|
|
|
149
149
|
### `to`
|
|
150
150
|
|
|
151
|
-
**Type**: [`RouteLocationRaw`](https://router.vuejs.org/api/interfaces/
|
|
151
|
+
**Type**: [`RouteLocationRaw`](https://router.vuejs.org/api/interfaces/routelocationoptions) | `undefined` | `null`
|
|
152
152
|
|
|
153
153
|
**Default**: `'/'`
|
|
154
154
|
|
|
@@ -186,9 +186,9 @@ An object accepting the following properties:
|
|
|
186
186
|
- **Type**: `number`
|
|
187
187
|
- **Default**: `302`
|
|
188
188
|
|
|
189
|
-
- `navigateTo` redirects to the given path and sets the redirect code to [`302 Found`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302) by default when the redirection takes place on the server side.
|
|
189
|
+
- `navigateTo` redirects to the given path and sets the redirect code to [`302 Found`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/302) by default when the redirection takes place on the server side.
|
|
190
190
|
|
|
191
|
-
This default behavior can be modified by providing different `redirectCode`. Commonly, [`301 Moved Permanently`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/301) can be used for permanent redirections.
|
|
191
|
+
This default behavior can be modified by providing different `redirectCode`. Commonly, [`301 Moved Permanently`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/301) can be used for permanent redirections.
|
|
192
192
|
|
|
193
193
|
- `external`
|
|
194
194
|
|
|
@@ -8,4 +8,4 @@ links:
|
|
|
8
8
|
size: xs
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
:read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/functions/
|
|
11
|
+
:read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/functions/onbeforerouteleave" title="Vue Router Docs" target="_blank"}
|
|
@@ -8,4 +8,4 @@ links:
|
|
|
8
8
|
size: xs
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
:read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/functions/
|
|
11
|
+
:read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/functions/onbeforerouteupdate" title="Vue Router Docs" target="_blank"}
|
|
@@ -36,7 +36,7 @@ const loggedIn = computed(() => !!tokenCookie.value)
|
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
::note{to="/docs/4.x/guide/going-further/experimental-features#cookiestore"}
|
|
39
|
-
|
|
39
|
+
Since [Nuxt v3.12.0](https://github.com/nuxt/nuxt/releases/tag/v3.12.0), the experimental `cookieStore` option is enabled by default. It automatically refreshes the `useCookie` value when cookies change in the browser.
|
|
40
40
|
::
|
|
41
41
|
|
|
42
42
|
## Type
|
|
@@ -9,7 +9,7 @@ links:
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
::note
|
|
12
|
-
Updates the [`app.config`](/docs/4.x/guide/directory-structure/app-config) using deep assignment. Existing (nested) properties will be preserved.
|
|
12
|
+
Updates the [`app.config`](/docs/4.x/guide/directory-structure/app/app-config) using deep assignment. Existing (nested) properties will be preserved.
|
|
13
13
|
::
|
|
14
14
|
|
|
15
15
|
## Usage
|
|
@@ -25,4 +25,4 @@ updateAppConfig(newAppConfig)
|
|
|
25
25
|
console.log(appConfig) // { foo: 'baz' }
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
:read-more{to="/docs/4.x/guide/directory-structure/app-config"}
|
|
28
|
+
:read-more{to="/docs/4.x/guide/directory-structure/app/app-config"}
|
package/3.api/5.kit/1.modules.md
CHANGED
|
@@ -47,7 +47,7 @@ export function defineNuxtModule<TOptions extends ModuleOptions> (
|
|
|
47
47
|
|
|
48
48
|
export function defineNuxtModule<TOptions extends ModuleOptions> (): {
|
|
49
49
|
with: <TOptionsDefaults extends Partial<TOptions>> (
|
|
50
|
-
definition: ModuleDefinition<TOptions, TOptionsDefaults, true> | NuxtModule<TOptions, TOptionsDefaults, true
|
|
50
|
+
definition: ModuleDefinition<TOptions, TOptionsDefaults, true> | NuxtModule<TOptions, TOptionsDefaults, true>,
|
|
51
51
|
) => NuxtModule<TOptions, TOptionsDefaults, true>
|
|
52
52
|
}
|
|
53
53
|
```
|
|
@@ -62,7 +62,7 @@ export function defineNuxtModule<TOptions extends ModuleOptions> (): {
|
|
|
62
62
|
| `defaults` | `T \| ((nuxt: Nuxt) => T)`{lang="ts"} | `false` | Default options for the module. If a function is provided, it will be called with the Nuxt instance as the first argument. |
|
|
63
63
|
| `schema` | `T` | `false` | Schema for the module options. If provided, options will be applied to the schema. |
|
|
64
64
|
| `hooks` | `Partial<NuxtHooks>`{lang="ts"} | `false` | Hooks to be installed for the module. If provided, the module will install the hooks. |
|
|
65
|
-
| `moduleDependencies` | `Record<string, ModuleDependency> \| ((nuxt: Nuxt) => Record<string, ModuleDependency>)`{lang="ts"} | `false` | Dependencies on other modules with version constraints and configuration. Can be an object or a function that receives the Nuxt instance. See [example](#specifying-module-dependencies). |
|
|
65
|
+
| `moduleDependencies` | `Record<string, ModuleDependency> \| ((nuxt: Nuxt) => Record<string, ModuleDependency>)`{lang="ts"} | `false` | Dependencies on other modules with version constraints and configuration. Can be an object or a function that receives the Nuxt instance. See [example](/docs/4.x/api/kit/modules#specifying-module-dependencies). |
|
|
66
66
|
| `onInstall` | `(nuxt: Nuxt) => Awaitable<void>`{lang="ts"} | `false` | Lifecycle hook called when the module is first installed. Requires `meta.name` and `meta.version` to be defined. |
|
|
67
67
|
| `onUpgrade` | `(options: T, nuxt: Nuxt, previousVersion: string) => Awaitable<void>`{lang="ts"} | `false` | Lifecycle hook called when the module is upgraded to a newer version. Requires `meta.name` and `meta.version` to be defined. |
|
|
68
68
|
| `setup` | `(this: void, resolvedOptions: T, nuxt: Nuxt) => Awaitable<void \| false \| ModuleSetupInstallResult>`{lang="ts"} | `false` | Setup function for the module. If provided, the module will call the setup function. |
|
|
@@ -324,7 +324,7 @@ export default defineNuxtModule({
|
|
|
324
324
|
## `installModule`
|
|
325
325
|
|
|
326
326
|
::callout{type="warning"}
|
|
327
|
-
**Deprecated:** Use the [`moduleDependencies`](#specifying-module-dependencies) option in `defineNuxtModule` instead. The `installModule` function will be removed (or may become non-blocking) in a future version.
|
|
327
|
+
**Deprecated:** Use the [`moduleDependencies`](/docs/4.x/api/kit/modules#specifying-module-dependencies) option in `defineNuxtModule` instead. The `installModule` function will be removed (or may become non-blocking) in a future version.
|
|
328
328
|
::
|
|
329
329
|
|
|
330
330
|
Install specified Nuxt module programmatically. This is helpful when your module depends on other modules. You can pass the module options as an object to `inlineOptions` and they will be passed to the module's `setup` function.
|
|
@@ -83,8 +83,8 @@ import type { ExtendViteConfigOptions } from '@nuxt/kit'
|
|
|
83
83
|
function extendViteConfig (callback: ((config: ViteConfig) => void), options?: ExtendViteConfigOptions): void
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
::read-more{to="https://vite.dev/config" target="_blank" icon="i-simple-icons-vite"}
|
|
87
|
-
|
|
86
|
+
::read-more{to="https://vite.dev/config/" target="_blank" icon="i-simple-icons-vite"}
|
|
87
|
+
Check out the Vite website for more information about its configuration.
|
|
88
88
|
::
|
|
89
89
|
|
|
90
90
|
### Parameters
|
|
@@ -132,8 +132,8 @@ import type { ExtendWebpackConfigOptions } from '@nuxt/kit'
|
|
|
132
132
|
function extendWebpackConfig (callback: ((config: WebpackConfig) => void), options?: ExtendWebpackConfigOptions): void
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
-
::read-more{to="https://webpack.js.org/configuration" target="_blank" icon="i-simple-icons-webpack"}
|
|
136
|
-
|
|
135
|
+
::read-more{to="https://webpack.js.org/configuration/" target="_blank" icon="i-simple-icons-webpack"}
|
|
136
|
+
Check out webpack website for more information about its configuration.
|
|
137
137
|
::
|
|
138
138
|
|
|
139
139
|
### Parameters
|
|
@@ -202,7 +202,7 @@ function addVitePlugin (pluginOrGetter: VitePlugin | VitePlugin[] | (() => ViteP
|
|
|
202
202
|
```
|
|
203
203
|
|
|
204
204
|
::tip
|
|
205
|
-
See [Vite website](https://vite.dev/guide/api-plugin
|
|
205
|
+
See [Vite website](https://vite.dev/guide/api-plugin) for more information about Vite plugins. You can also use [this repository](https://github.com/vitejs/awesome-vite#plugins) to find a plugin that suits your needs.
|
|
206
206
|
::
|
|
207
207
|
|
|
208
208
|
### Parameters
|
|
@@ -261,7 +261,7 @@ function addWebpackPlugin (pluginOrGetter: WebpackPluginInstance | WebpackPlugin
|
|
|
261
261
|
```
|
|
262
262
|
|
|
263
263
|
::tip
|
|
264
|
-
See [webpack website](https://webpack.js.org/concepts/plugins) for more information about webpack plugins. You can also use [this collection](https://webpack.js.org/awesome-webpack/#webpack-plugins) to find a plugin that suits your needs.
|
|
264
|
+
See [webpack website](https://webpack.js.org/concepts/plugins/) for more information about webpack plugins. You can also use [this collection](https://webpack.js.org/awesome-webpack/#webpack-plugins) to find a plugin that suits your needs.
|
|
265
265
|
::
|
|
266
266
|
|
|
267
267
|
### Parameters
|
|
@@ -8,7 +8,7 @@ links:
|
|
|
8
8
|
size: xs
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
Programmatic usage can be helpful when you want to use Nuxt programmatically, for example, when building a [CLI tool](https://github.com/nuxt/cli) or [test utils](https://github.com/nuxt/
|
|
11
|
+
Programmatic usage can be helpful when you want to use Nuxt programmatically, for example, when building a [CLI tool](https://github.com/nuxt/cli) or [test utils](https://github.com/nuxt/test-utils).
|
|
12
12
|
|
|
13
13
|
## `loadNuxt`
|
|
14
14
|
|
|
@@ -31,7 +31,7 @@ function loadNuxt (loadOptions?: LoadNuxtOptions): Promise<Nuxt>
|
|
|
31
31
|
|
|
32
32
|
## `buildNuxt`
|
|
33
33
|
|
|
34
|
-
Build Nuxt programmatically. It will invoke the builder (currently [@nuxt/vite-builder](https://github.com/nuxt/nuxt/
|
|
34
|
+
Build Nuxt programmatically. It will invoke the builder (currently [@nuxt/vite-builder](https://github.com/nuxt/nuxt/blob/main/packages/vite) or [@nuxt/webpack-builder](https://github.com/nuxt/nuxt/blob/main/packages/webpack)) to bundle the application.
|
|
35
35
|
|
|
36
36
|
### Type
|
|
37
37
|
|
|
@@ -15,20 +15,20 @@ Hook | Arguments | Environment | Description
|
|
|
15
15
|
`app:error` | `err` | Server & Client | Called when a fatal error occurs.
|
|
16
16
|
`app:error:cleared` | `{ redirect? }` | Server & Client | Called when a fatal error occurs.
|
|
17
17
|
`vue:setup` | - | Server & Client | Called when the setup of Nuxt root is initialized. This callback must be synchronous.
|
|
18
|
-
`vue:error` | `err, target, info` | Server & Client | Called when a vue error propagates to the root component. [Learn More](https://vuejs.org/api/composition-api-lifecycle
|
|
18
|
+
`vue:error` | `err, target, info` | Server & Client | Called when a vue error propagates to the root component. [Learn More](https://vuejs.org/api/composition-api-lifecycle#onerrorcaptured).
|
|
19
19
|
`app:rendered` | `renderContext` | Server | Called when SSR rendering is done.
|
|
20
20
|
`app:redirected` | - | Server | Called before SSR redirection.
|
|
21
21
|
`app:beforeMount` | `vueApp` | Client | Called before mounting the app, called only on client side.
|
|
22
22
|
`app:mounted` | `vueApp` | Client | Called when Vue app is initialized and mounted in browser.
|
|
23
|
-
`app:suspense:resolve` | `appComponent` | Client | On [Suspense](https://vuejs.org/guide/built-ins/suspense
|
|
23
|
+
`app:suspense:resolve` | `appComponent` | Client | On [Suspense](https://vuejs.org/guide/built-ins/suspense#suspense) resolved event.
|
|
24
24
|
`app:manifest:update` | `{ id, timestamp }` | Client | Called when there is a newer version of your app detected.
|
|
25
25
|
`app:data:refresh` | `keys?` | Client | Called when `refreshNuxtData` is called.
|
|
26
26
|
`link:prefetch` | `to` | Client | Called when a `<NuxtLink>` is observed to be prefetched.
|
|
27
|
-
`page:start` | `pageComponent?` | Client | Called on [Suspense](https://vuejs.org/guide/built-ins/suspense
|
|
28
|
-
`page:finish` | `pageComponent?` | Client | Called on [Suspense](https://vuejs.org/guide/built-ins/suspense
|
|
27
|
+
`page:start` | `pageComponent?` | Client | Called on [Suspense](https://vuejs.org/guide/built-ins/suspense#suspense) inside of `NuxtPage` pending event.
|
|
28
|
+
`page:finish` | `pageComponent?` | Client | Called on [Suspense](https://vuejs.org/guide/built-ins/suspense#suspense) inside of `NuxtPage` resolved event.
|
|
29
29
|
`page:loading:start` | - | Client | Called when the `setup()` of the new page is running.
|
|
30
30
|
`page:loading:end` | - | Client | Called after `page:finish`
|
|
31
|
-
`page:transition:finish`| `pageComponent?` | Client | After page transition [onAfterLeave](https://vuejs.org/guide/built-ins/transition
|
|
31
|
+
`page:transition:finish`| `pageComponent?` | Client | After page transition [onAfterLeave](https://vuejs.org/guide/built-ins/transition#javascript-hooks) event.
|
|
32
32
|
`dev:ssr-logs` | `logs` | Client | Called with an array of server-side logs that have been passed to the client (if `features.devLogs` is enabled).
|
|
33
33
|
`page:view-transition:start` | `transition` | Client | Called after `document.startViewTransition` is called when [experimental viewTransition support is enabled](/docs/4.x/getting-started/transitions#view-transitions-api-experimental).
|
|
34
34
|
|