@nuxt/docs 4.1.2 → 4.2.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 +6 -6
- package/1.getting-started/02.installation.md +3 -2
- package/1.getting-started/03.configuration.md +36 -36
- package/1.getting-started/04.views.md +9 -9
- package/1.getting-started/05.assets.md +15 -9
- package/1.getting-started/06.styling.md +58 -48
- package/1.getting-started/07.routing.md +17 -17
- package/1.getting-started/08.seo-meta.md +59 -46
- package/1.getting-started/09.transitions.md +49 -44
- package/1.getting-started/10.data-fetching.md +104 -81
- package/1.getting-started/11.state-management.md +26 -19
- package/1.getting-started/12.error-handling.md +22 -20
- package/1.getting-started/13.server.md +8 -8
- package/1.getting-started/14.layers.md +22 -16
- package/1.getting-started/15.prerendering.md +32 -32
- package/1.getting-started/16.deployment.md +10 -10
- package/1.getting-started/17.testing.md +44 -44
- package/1.getting-started/18.upgrade.md +241 -110
- package/2.guide/0.index.md +7 -7
- package/2.guide/{2.directory-structure → 1.directory-structure}/.navigation.yml +1 -1
- package/2.guide/{2.directory-structure → 1.directory-structure}/0.nuxt.md +3 -3
- package/2.guide/1.directory-structure/0.output.md +18 -0
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/.navigation.yml +1 -1
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.assets.md +4 -4
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.components.md +45 -28
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.composables.md +13 -13
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.layouts.md +19 -15
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.middleware.md +31 -25
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.pages.md +39 -37
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.plugins.md +25 -25
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.utils.md +7 -7
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/3.app-config.md +18 -18
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/3.app.md +7 -7
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/3.error.md +6 -6
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.content.md +7 -4
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.modules.md +8 -8
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.node_modules.md +2 -2
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.public.md +2 -2
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.server.md +35 -35
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.shared.md +7 -7
- package/2.guide/{2.directory-structure → 1.directory-structure}/2.env.md +8 -8
- package/2.guide/{2.directory-structure → 1.directory-structure}/2.gitignore.md +1 -1
- package/2.guide/{2.directory-structure → 1.directory-structure}/2.nuxtignore.md +5 -4
- package/2.guide/{2.directory-structure → 1.directory-structure}/2.nuxtrc.md +4 -4
- package/2.guide/{2.directory-structure → 1.directory-structure}/3.nuxt-config.md +3 -3
- package/2.guide/{2.directory-structure → 1.directory-structure}/3.package.md +1 -1
- package/2.guide/{2.directory-structure → 1.directory-structure}/3.tsconfig.md +3 -3
- package/2.guide/{1.concepts → 2.concepts}/1.auto-imports.md +22 -22
- package/2.guide/{1.concepts → 2.concepts}/10.nuxt-lifecycle.md +17 -17
- package/2.guide/{1.concepts → 2.concepts}/2.vuejs-development.md +13 -13
- package/2.guide/{1.concepts → 2.concepts}/3.rendering.md +24 -22
- package/2.guide/{1.concepts → 2.concepts}/4.server-engine.md +6 -6
- package/2.guide/{1.concepts → 2.concepts}/5.modules.md +5 -5
- package/2.guide/{1.concepts → 2.concepts}/7.esm.md +22 -16
- package/2.guide/{1.concepts → 2.concepts}/8.typescript.md +12 -12
- package/2.guide/3.going-further/1.events.md +3 -3
- package/2.guide/3.going-further/1.experimental-features.md +334 -85
- package/2.guide/3.going-further/1.features.md +58 -11
- package/2.guide/3.going-further/1.internals.md +25 -25
- package/2.guide/3.going-further/10.runtime-config.md +12 -12
- package/2.guide/3.going-further/11.nightly-release-channel.md +1 -1
- package/2.guide/3.going-further/2.hooks.md +14 -14
- package/2.guide/3.going-further/3.modules.md +126 -108
- package/2.guide/3.going-further/4.kit.md +7 -7
- package/2.guide/3.going-further/6.nuxt-app.md +8 -8
- package/2.guide/3.going-further/7.layers.md +76 -59
- package/2.guide/3.going-further/9.debugging.md +2 -2
- package/2.guide/4.recipes/1.custom-routing.md +30 -30
- package/2.guide/4.recipes/2.vite-plugin.md +45 -4
- package/2.guide/4.recipes/3.custom-usefetch.md +13 -13
- package/2.guide/4.recipes/4.sessions-and-authentication.md +35 -21
- package/2.guide/5.best-practices/hydration.md +4 -4
- package/2.guide/5.best-practices/performance.md +17 -17
- package/3.api/1.components/1.client-only.md +6 -3
- package/3.api/1.components/1.nuxt-client-fallback.md +10 -7
- package/3.api/1.components/10.nuxt-picture.md +1 -1
- package/3.api/1.components/11.teleports.md +5 -2
- package/3.api/1.components/12.nuxt-route-announcer.md +9 -9
- package/3.api/1.components/13.nuxt-time.md +49 -18
- package/3.api/1.components/2.nuxt-page.md +6 -6
- package/3.api/1.components/3.nuxt-layout.md +15 -10
- package/3.api/1.components/4.nuxt-link.md +42 -22
- package/3.api/1.components/5.nuxt-loading-indicator.md +3 -3
- package/3.api/1.components/6.nuxt-error-boundary.md +12 -10
- package/3.api/2.composables/on-prehydrate.md +2 -2
- package/3.api/2.composables/use-app-config.md +1 -1
- package/3.api/2.composables/use-async-data.md +26 -22
- package/3.api/2.composables/use-cookie.md +29 -21
- package/3.api/2.composables/use-error.md +2 -2
- package/3.api/2.composables/use-fetch.md +62 -32
- package/3.api/2.composables/use-head-safe.md +7 -7
- package/3.api/2.composables/use-head.md +5 -5
- package/3.api/2.composables/use-hydration.md +6 -6
- package/3.api/2.composables/use-lazy-async-data.md +4 -4
- package/3.api/2.composables/use-lazy-fetch.md +4 -4
- package/3.api/2.composables/use-loading-indicator.md +12 -12
- package/3.api/2.composables/use-nuxt-app.md +22 -22
- package/3.api/2.composables/use-nuxt-data.md +8 -8
- package/3.api/2.composables/use-preview-mode.md +15 -18
- package/3.api/2.composables/use-request-event.md +1 -1
- package/3.api/2.composables/use-request-fetch.md +3 -3
- package/3.api/2.composables/use-request-header.md +1 -1
- package/3.api/2.composables/use-request-headers.md +4 -4
- package/3.api/2.composables/use-request-url.md +1 -1
- package/3.api/2.composables/use-response-header.md +9 -10
- package/3.api/2.composables/use-route-announcer.md +4 -4
- package/3.api/2.composables/use-route.md +1 -1
- package/3.api/2.composables/use-router.md +10 -8
- package/3.api/2.composables/use-runtime-config.md +11 -11
- package/3.api/2.composables/use-runtime-hook.md +2 -2
- package/3.api/2.composables/use-seo-meta.md +4 -4
- package/3.api/2.composables/use-server-seo-meta.md +6 -6
- package/3.api/2.composables/use-state.md +5 -5
- package/3.api/3.utils/$fetch.md +10 -8
- package/3.api/3.utils/abort-navigation.md +3 -3
- package/3.api/3.utils/add-route-middleware.md +5 -5
- package/3.api/3.utils/call-once.md +6 -6
- package/3.api/3.utils/clear-error.md +3 -3
- package/3.api/3.utils/clear-nuxt-data.md +3 -3
- package/3.api/3.utils/clear-nuxt-state.md +3 -3
- package/3.api/3.utils/create-error.md +2 -2
- package/3.api/3.utils/define-lazy-hydration-component.md +13 -13
- package/3.api/3.utils/define-nuxt-component.md +5 -5
- package/3.api/3.utils/define-nuxt-plugin.md +13 -13
- package/3.api/3.utils/define-nuxt-route-middleware.md +5 -5
- package/3.api/3.utils/define-page-meta.md +23 -23
- package/3.api/3.utils/define-route-rules.md +7 -7
- package/3.api/3.utils/navigate-to.md +11 -11
- package/3.api/3.utils/prefetch-components.md +1 -1
- package/3.api/3.utils/preload-components.md +1 -1
- package/3.api/3.utils/preload-route-components.md +2 -2
- package/3.api/3.utils/prerender-routes.md +3 -3
- package/3.api/3.utils/refresh-cookie.md +4 -4
- package/3.api/3.utils/refresh-nuxt-data.md +12 -7
- package/3.api/3.utils/reload-nuxt-app.md +3 -3
- package/3.api/3.utils/set-page-layout.md +1 -1
- package/3.api/3.utils/set-response-status.md +3 -3
- package/3.api/3.utils/show-error.md +5 -5
- package/3.api/3.utils/update-app-config.md +4 -3
- package/3.api/4.commands/add.md +1 -1
- package/3.api/4.commands/analyze.md +2 -1
- package/3.api/4.commands/build.md +2 -1
- package/3.api/4.commands/dev.md +5 -4
- package/3.api/4.commands/generate.md +3 -2
- package/3.api/4.commands/init.md +3 -2
- package/3.api/4.commands/module.md +4 -4
- package/3.api/4.commands/prepare.md +7 -2
- package/3.api/4.commands/preview.md +5 -4
- package/3.api/4.commands/test.md +40 -0
- package/3.api/4.commands/typecheck.md +5 -3
- package/3.api/4.commands/upgrade.md +3 -3
- package/3.api/5.kit/1.modules.md +123 -37
- package/3.api/5.kit/10.runtime-config.md +1 -1
- package/3.api/5.kit/10.templates.md +8 -6
- package/3.api/5.kit/11.nitro.md +66 -62
- package/3.api/5.kit/12.resolving.md +2 -2
- package/3.api/5.kit/14.builder.md +61 -4
- package/3.api/5.kit/15.examples.md +5 -7
- package/3.api/5.kit/16.layers.md +26 -26
- package/3.api/5.kit/3.compatibility.md +14 -14
- package/3.api/5.kit/4.autoimports.md +13 -13
- package/3.api/5.kit/5.components.md +8 -7
- package/3.api/5.kit/6.context.md +3 -3
- package/3.api/5.kit/7.pages.md +7 -7
- package/3.api/5.kit/8.layout.md +2 -2
- package/3.api/5.kit/9.head.md +132 -0
- package/3.api/5.kit/9.plugins.md +5 -4
- package/3.api/6.advanced/1.hooks.md +5 -5
- package/3.api/6.advanced/2.import-meta.md +3 -3
- package/3.api/6.nuxt-config.md +365 -859
- package/3.api/index.md +7 -7
- package/5.community/2.getting-help.md +1 -1
- package/5.community/3.reporting-bugs.md +3 -3
- package/5.community/4.contribution.md +11 -11
- package/5.community/5.framework-contribution.md +4 -4
- package/5.community/6.roadmap.md +2 -2
- package/6.bridge/1.overview.md +13 -13
- package/6.bridge/10.configuration.md +2 -1
- package/6.bridge/2.typescript.md +3 -3
- package/6.bridge/3.bridge-composition-api.md +8 -8
- package/6.bridge/4.plugins-and-middleware.md +9 -9
- package/6.bridge/5.nuxt3-compatible-api.md +20 -17
- package/6.bridge/6.meta.md +20 -19
- package/6.bridge/7.runtime-config.md +1 -1
- package/6.bridge/8.nitro.md +3 -3
- package/6.bridge/9.vite.md +4 -4
- package/7.migration/1.overview.md +2 -2
- package/7.migration/10.bundling.md +1 -1
- package/7.migration/11.server.md +3 -3
- package/7.migration/2.configuration.md +23 -21
- package/7.migration/20.module-authors.md +7 -7
- package/7.migration/3.auto-imports.md +3 -3
- package/7.migration/4.meta.md +21 -18
- package/7.migration/5.plugins-and-middleware.md +8 -8
- package/7.migration/6.pages-and-layouts.md +28 -24
- package/7.migration/7.component-options.md +18 -18
- package/7.migration/8.runtime-config.md +7 -7
- package/package.json +1 -1
- package/2.guide/2.directory-structure/0.output.md +0 -18
- /package/2.guide/{1.concepts → 2.concepts}/.navigation.yml +0 -0
- /package/2.guide/{1.concepts → 2.concepts}/9.code-style.md +0 -0
|
@@ -165,10 +165,10 @@ Watch Vue School video about createResolver.
|
|
|
165
165
|
### Usage
|
|
166
166
|
|
|
167
167
|
```ts
|
|
168
|
-
import {
|
|
168
|
+
import { createResolver, defineNuxtModule } from '@nuxt/kit'
|
|
169
169
|
|
|
170
170
|
export default defineNuxtModule({
|
|
171
|
-
|
|
171
|
+
setup (_, nuxt) {
|
|
172
172
|
const { resolve, resolvePath } = createResolver(import.meta.url)
|
|
173
173
|
},
|
|
174
174
|
})
|
|
@@ -14,6 +14,10 @@ Nuxt have builders based on [Vite](https://github.com/nuxt/nuxt/tree/main/packag
|
|
|
14
14
|
|
|
15
15
|
Extends the Vite configuration. Callback function can be called multiple times, when applying to both client and server builds.
|
|
16
16
|
|
|
17
|
+
::warning
|
|
18
|
+
This hook is now deprecated, and we recommend using a Vite plugin instead with a `config` hook, or — for environment-specific configuration — the `applyToEnvironment` hook.
|
|
19
|
+
::
|
|
20
|
+
|
|
17
21
|
### Usage
|
|
18
22
|
|
|
19
23
|
```ts twoslash
|
|
@@ -30,6 +34,45 @@ export default defineNuxtModule({
|
|
|
30
34
|
})
|
|
31
35
|
```
|
|
32
36
|
|
|
37
|
+
For environment-specific configuration in Nuxt 5+, use `addVitePlugin()` instead:
|
|
38
|
+
|
|
39
|
+
```ts twoslash
|
|
40
|
+
import { addVitePlugin, defineNuxtModule } from '@nuxt/kit'
|
|
41
|
+
|
|
42
|
+
export default defineNuxtModule({
|
|
43
|
+
setup () {
|
|
44
|
+
// For global configuration (affects all environments)
|
|
45
|
+
addVitePlugin(() => ({
|
|
46
|
+
name: 'my-global-plugin',
|
|
47
|
+
config (config) {
|
|
48
|
+
// This runs before environment setup
|
|
49
|
+
config.optimizeDeps ||= {}
|
|
50
|
+
config.optimizeDeps.include ||= []
|
|
51
|
+
config.optimizeDeps.include.push('cross-fetch')
|
|
52
|
+
},
|
|
53
|
+
}))
|
|
54
|
+
|
|
55
|
+
// For environment-specific configuration
|
|
56
|
+
addVitePlugin(() => ({
|
|
57
|
+
name: 'my-client-plugin',
|
|
58
|
+
applyToEnvironment (environment) {
|
|
59
|
+
return environment.name === 'client'
|
|
60
|
+
},
|
|
61
|
+
configEnvironment (name, config) {
|
|
62
|
+
// This only affects the client environment
|
|
63
|
+
config.optimizeDeps ||= {}
|
|
64
|
+
config.optimizeDeps.include ||= []
|
|
65
|
+
config.optimizeDeps.include.push('client-only-package')
|
|
66
|
+
},
|
|
67
|
+
}))
|
|
68
|
+
},
|
|
69
|
+
})
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
::warning
|
|
73
|
+
**Important:** The `config` hook runs before `applyToEnvironment` and modifies the global configuration. Use `configEnvironment` for environment-specific configuration changes.
|
|
74
|
+
::
|
|
75
|
+
|
|
33
76
|
### Type
|
|
34
77
|
|
|
35
78
|
```ts twoslash
|
|
@@ -54,8 +97,8 @@ Checkout Vite website for more information about its configuration.
|
|
|
54
97
|
| --------- | --------- | -------- | ------------------------------------------------------------------------------------------------------------ |
|
|
55
98
|
| `dev` | `boolean` | `false` | If set to `true`, the callback function will be called when building in development mode. |
|
|
56
99
|
| `build` | `boolean` | `false` | If set to `true`, the callback function will be called when building in production mode. |
|
|
57
|
-
| `server` | `boolean` | `false` | If set to `true`, the callback function will be called when building the server bundle.
|
|
58
|
-
| `client` | `boolean` | `false` | If set to `true`, the callback function will be called when building the client bundle.
|
|
100
|
+
| `server` | `boolean` | `false` | If set to `true`, the callback function will be called when building the server bundle. **Deprecated in Nuxt 5+.** Use `addVitePlugin()` with `applyToEnvironment()` instead. |
|
|
101
|
+
| `client` | `boolean` | `false` | If set to `true`, the callback function will be called when building the client bundle. **Deprecated in Nuxt 5+.** Use `addVitePlugin()` with `applyToEnvironment()` instead. |
|
|
59
102
|
| `prepend` | `boolean` | `false` | If set to `true`, the callback function will be prepended to the array with `unshift()` instead of `push()`. |
|
|
60
103
|
|
|
61
104
|
## `extendWebpackConfig`
|
|
@@ -111,6 +154,10 @@ Checkout webpack website for more information about its configuration.
|
|
|
111
154
|
|
|
112
155
|
Append Vite plugin to the config.
|
|
113
156
|
|
|
157
|
+
::warning
|
|
158
|
+
In Nuxt 5+, plugins registered with `server: false` or `client: false` options will not have their `config` or `configResolved` hooks called. Instead, use the `applyToEnvironment()` method instead for environment-specific plugins.
|
|
159
|
+
::
|
|
160
|
+
|
|
114
161
|
### Usage
|
|
115
162
|
|
|
116
163
|
```ts twoslash
|
|
@@ -131,6 +178,15 @@ export default defineNuxtModule({
|
|
|
131
178
|
},
|
|
132
179
|
setup (options) {
|
|
133
180
|
addVitePlugin(svg4VuePlugin(options.svg4vue))
|
|
181
|
+
|
|
182
|
+
// or, to add a vite plugin to only one environment
|
|
183
|
+
addVitePlugin(() => ({
|
|
184
|
+
name: 'my-client-plugin',
|
|
185
|
+
applyToEnvironment (environment) {
|
|
186
|
+
return environment.name === 'client'
|
|
187
|
+
},
|
|
188
|
+
// ... rest of your client-only plugin
|
|
189
|
+
}))
|
|
134
190
|
},
|
|
135
191
|
})
|
|
136
192
|
```
|
|
@@ -159,8 +215,8 @@ See [Vite website](https://vite.dev/guide/api-plugin.html) for more information
|
|
|
159
215
|
| --------- | --------- | -------- | ------------------------------------------------------------------------------------------------------------ |
|
|
160
216
|
| `dev` | `boolean` | `false` | If set to `true`, the callback function will be called when building in development mode. |
|
|
161
217
|
| `build` | `boolean` | `false` | If set to `true`, the callback function will be called when building in production mode. |
|
|
162
|
-
| `server` | `boolean` | `false` | If set to `true`, the callback function will be called when building the server bundle.
|
|
163
|
-
| `client` | `boolean` | `false` | If set to `true`, the callback function will be called when building the client bundle.
|
|
218
|
+
| `server` | `boolean` | `false` | If set to `true`, the callback function will be called when building the server bundle. **Deprecated in Nuxt 5+.** Use `applyToEnvironment()` instead. |
|
|
219
|
+
| `client` | `boolean` | `false` | If set to `true`, the callback function will be called when building the client bundle. **Deprecated in Nuxt 5+.** Use `applyToEnvironment()` instead. |
|
|
164
220
|
| `prepend` | `boolean` | `false` | If set to `true`, the callback function will be prepended to the array with `unshift()` instead of `push()`. |
|
|
165
221
|
|
|
166
222
|
## `addWebpackPlugin`
|
|
@@ -234,6 +290,7 @@ import type { ExtendConfigOptions } from '@nuxt/kit'
|
|
|
234
290
|
import type { Plugin as VitePlugin } from 'vite'
|
|
235
291
|
import type { WebpackPluginInstance } from 'webpack'
|
|
236
292
|
import type { RspackPluginInstance } from '@rspack/core'
|
|
293
|
+
|
|
237
294
|
interface AddBuildPluginFactory {
|
|
238
295
|
vite?: () => VitePlugin | VitePlugin[]
|
|
239
296
|
webpack?: () => WebpackPluginInstance | WebpackPluginInstance[]
|
|
@@ -16,17 +16,15 @@ Some examples of projects doing this already:
|
|
|
16
16
|
Here is a brief example of how you might access the Vite config from a project; you could implement a similar approach to get the webpack configuration.
|
|
17
17
|
|
|
18
18
|
```js
|
|
19
|
-
import {
|
|
19
|
+
import { buildNuxt, loadNuxt } from '@nuxt/kit'
|
|
20
20
|
|
|
21
21
|
// https://github.com/nuxt/nuxt/issues/14534
|
|
22
|
-
async function getViteConfig() {
|
|
22
|
+
async function getViteConfig () {
|
|
23
23
|
const nuxt = await loadNuxt({ cwd: process.cwd(), dev: false, overrides: { ssr: false } })
|
|
24
24
|
return new Promise((resolve, reject) => {
|
|
25
|
-
nuxt.hook('vite:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
throw new Error('_stop_')
|
|
29
|
-
}
|
|
25
|
+
nuxt.hook('vite:extend', (config) => {
|
|
26
|
+
resolve(config)
|
|
27
|
+
throw new Error('_stop_')
|
|
30
28
|
})
|
|
31
29
|
buildNuxt(nuxt).catch((err) => {
|
|
32
30
|
if (!err.toString().includes('_stop_')) {
|
package/3.api/5.kit/16.layers.md
CHANGED
|
@@ -20,9 +20,9 @@ Get the resolved directory paths for all layers in a Nuxt application. This func
|
|
|
20
20
|
import { defineNuxtModule, getLayerDirectories } from '@nuxt/kit'
|
|
21
21
|
|
|
22
22
|
export default defineNuxtModule({
|
|
23
|
-
setup() {
|
|
23
|
+
setup () {
|
|
24
24
|
const layerDirs = getLayerDirectories()
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
// Access directories from all layers
|
|
27
27
|
for (const [index, layer] of layerDirs.entries()) {
|
|
28
28
|
console.log(`Layer ${index}:`)
|
|
@@ -32,7 +32,7 @@ export default defineNuxtModule({
|
|
|
32
32
|
console.log(` Pages: ${layer.appPages}`)
|
|
33
33
|
// ... other directories
|
|
34
34
|
}
|
|
35
|
-
}
|
|
35
|
+
},
|
|
36
36
|
})
|
|
37
37
|
```
|
|
38
38
|
|
|
@@ -42,7 +42,7 @@ export default defineNuxtModule({
|
|
|
42
42
|
// @errors: 2391
|
|
43
43
|
import type { Nuxt } from '@nuxt/schema'
|
|
44
44
|
// ---cut---
|
|
45
|
-
function getLayerDirectories(nuxt?: Nuxt): LayerDirectories[]
|
|
45
|
+
function getLayerDirectories (nuxt?: Nuxt): LayerDirectories[]
|
|
46
46
|
|
|
47
47
|
interface LayerDirectories {
|
|
48
48
|
/** Nuxt rootDir (`/` by default) */
|
|
@@ -110,9 +110,9 @@ import { resolve } from 'pathe'
|
|
|
110
110
|
import { globby } from 'globby'
|
|
111
111
|
|
|
112
112
|
export default defineNuxtModule({
|
|
113
|
-
async setup() {
|
|
113
|
+
async setup () {
|
|
114
114
|
const layerDirs = getLayerDirectories()
|
|
115
|
-
|
|
115
|
+
|
|
116
116
|
// Find all component files across layers
|
|
117
117
|
// Note: layerDirs[0] is the user layer (highest priority)
|
|
118
118
|
// Later layers in the array have lower priority
|
|
@@ -120,37 +120,37 @@ export default defineNuxtModule({
|
|
|
120
120
|
for (const [index, layer] of layerDirs.entries()) {
|
|
121
121
|
const files = await globby('**/*.vue', {
|
|
122
122
|
cwd: resolve(layer.app, 'components'),
|
|
123
|
-
absolute: true
|
|
123
|
+
absolute: true,
|
|
124
124
|
})
|
|
125
125
|
console.log(`Layer ${index} (${index === 0 ? 'user' : 'base'}):`, files.length, 'components')
|
|
126
126
|
componentFiles.push(...files)
|
|
127
127
|
}
|
|
128
|
-
}
|
|
128
|
+
},
|
|
129
129
|
})
|
|
130
130
|
```
|
|
131
131
|
|
|
132
132
|
**Adding templates from multiple layers:**
|
|
133
133
|
|
|
134
134
|
```ts twoslash
|
|
135
|
-
import { defineNuxtModule, getLayerDirectories
|
|
136
|
-
import {
|
|
137
|
-
import { existsSync } from 'fs'
|
|
135
|
+
import { addTemplate, defineNuxtModule, getLayerDirectories } from '@nuxt/kit'
|
|
136
|
+
import { basename, resolve } from 'pathe'
|
|
137
|
+
import { existsSync } from 'node:fs'
|
|
138
138
|
|
|
139
139
|
export default defineNuxtModule({
|
|
140
|
-
|
|
140
|
+
setup () {
|
|
141
141
|
const layerDirs = getLayerDirectories()
|
|
142
|
-
|
|
142
|
+
|
|
143
143
|
// Add a config file from each layer that has one
|
|
144
144
|
for (const dirs of layerDirs) {
|
|
145
145
|
const configPath = resolve(dirs.app, 'my-module.config.ts')
|
|
146
146
|
if (existsSync(configPath)) {
|
|
147
147
|
addTemplate({
|
|
148
148
|
filename: `my-module-${basename(dirs.root)}.config.ts`,
|
|
149
|
-
src: configPath
|
|
149
|
+
src: configPath,
|
|
150
150
|
})
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
}
|
|
153
|
+
},
|
|
154
154
|
})
|
|
155
155
|
```
|
|
156
156
|
|
|
@@ -159,12 +159,12 @@ export default defineNuxtModule({
|
|
|
159
159
|
```ts twoslash
|
|
160
160
|
import { defineNuxtModule, getLayerDirectories } from '@nuxt/kit'
|
|
161
161
|
import { resolve } from 'pathe'
|
|
162
|
-
import { existsSync, readFileSync } from 'fs'
|
|
162
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
163
163
|
|
|
164
164
|
export default defineNuxtModule({
|
|
165
|
-
setup() {
|
|
165
|
+
setup () {
|
|
166
166
|
const layerDirs = getLayerDirectories()
|
|
167
|
-
|
|
167
|
+
|
|
168
168
|
// Find the first (highest priority) layer that has a specific config file
|
|
169
169
|
// This respects the layer priority system
|
|
170
170
|
let configContent = null
|
|
@@ -176,7 +176,7 @@ export default defineNuxtModule({
|
|
|
176
176
|
break // Use the first (highest priority) config found
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
-
|
|
179
|
+
|
|
180
180
|
// Alternative: Collect configs from all layers, with user layer taking precedence
|
|
181
181
|
const allConfigs = {}
|
|
182
182
|
for (const dirs of layerDirs.reverse()) { // Process from lowest to highest priority
|
|
@@ -186,7 +186,7 @@ export default defineNuxtModule({
|
|
|
186
186
|
Object.assign(allConfigs, config) // Later assignments override earlier ones
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
}
|
|
189
|
+
},
|
|
190
190
|
})
|
|
191
191
|
```
|
|
192
192
|
|
|
@@ -194,20 +194,20 @@ export default defineNuxtModule({
|
|
|
194
194
|
|
|
195
195
|
```ts twoslash
|
|
196
196
|
import { defineNuxtModule, getLayerDirectories } from '@nuxt/kit'
|
|
197
|
-
import { existsSync } from 'fs'
|
|
197
|
+
import { existsSync } from 'node:fs'
|
|
198
198
|
import { resolve } from 'pathe'
|
|
199
199
|
|
|
200
200
|
export default defineNuxtModule({
|
|
201
|
-
setup() {
|
|
201
|
+
setup () {
|
|
202
202
|
const layerDirs = getLayerDirectories()
|
|
203
|
-
|
|
203
|
+
|
|
204
204
|
// Find layers that have a specific custom directory
|
|
205
|
-
const layersWithAssets = layerDirs.filter(layer => {
|
|
205
|
+
const layersWithAssets = layerDirs.filter((layer) => {
|
|
206
206
|
return existsSync(resolve(layer.app, 'assets'))
|
|
207
207
|
})
|
|
208
|
-
|
|
208
|
+
|
|
209
209
|
console.log(`Found ${layersWithAssets.length} layers with assets directory`)
|
|
210
|
-
}
|
|
210
|
+
},
|
|
211
211
|
})
|
|
212
212
|
```
|
|
213
213
|
|
|
@@ -17,7 +17,7 @@ Checks if constraints are met for the current Nuxt version. If not, returns an a
|
|
|
17
17
|
### Usage
|
|
18
18
|
|
|
19
19
|
```ts twoslash
|
|
20
|
-
import {
|
|
20
|
+
import { checkNuxtCompatibility, defineNuxtModule } from '@nuxt/kit'
|
|
21
21
|
|
|
22
22
|
export default defineNuxtModule({
|
|
23
23
|
async setup (_options, nuxt) {
|
|
@@ -27,14 +27,14 @@ export default defineNuxtModule({
|
|
|
27
27
|
} else {
|
|
28
28
|
// do something
|
|
29
29
|
}
|
|
30
|
-
}
|
|
30
|
+
},
|
|
31
31
|
})
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
### Type
|
|
35
35
|
|
|
36
36
|
```ts
|
|
37
|
-
function checkNuxtCompatibility(constraints: NuxtCompatibility, nuxt?: Nuxt): Promise<NuxtCompatibilityIssues
|
|
37
|
+
function checkNuxtCompatibility (constraints: NuxtCompatibility, nuxt?: Nuxt): Promise<NuxtCompatibilityIssues>
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
### Parameters
|
|
@@ -58,12 +58,12 @@ Asserts that constraints are met for the current Nuxt version. If not, throws an
|
|
|
58
58
|
// @errors: 2391
|
|
59
59
|
import type { Nuxt, NuxtCompatibility } from '@nuxt/schema'
|
|
60
60
|
// ---cut---
|
|
61
|
-
function assertNuxtCompatibility(constraints: NuxtCompatibility, nuxt?: Nuxt): Promise<true
|
|
61
|
+
function assertNuxtCompatibility (constraints: NuxtCompatibility, nuxt?: Nuxt): Promise<true>
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
### Parameters
|
|
65
65
|
|
|
66
|
-
**`constraints`**: Version and builder constraints to check against. Refer to the [constraints table in `checkNuxtCompatibility`](#parameters) for details.
|
|
66
|
+
**`constraints`**: Version and builder constraints to check against. Refer to the [constraints table in `checkNuxtCompatibility`](/docs/4.x/api/kit/compatibility#parameters) for details.
|
|
67
67
|
|
|
68
68
|
**`nuxt`**: Nuxt instance. If not provided, it will be retrieved from the context via `useNuxt()` call.
|
|
69
69
|
|
|
@@ -84,19 +84,19 @@ export default defineNuxtModule({
|
|
|
84
84
|
} else {
|
|
85
85
|
// do something else
|
|
86
86
|
}
|
|
87
|
-
}
|
|
87
|
+
},
|
|
88
88
|
})
|
|
89
89
|
```
|
|
90
90
|
|
|
91
91
|
### Type
|
|
92
92
|
|
|
93
93
|
```ts
|
|
94
|
-
function hasNuxtCompatibility(constraints: NuxtCompatibility, nuxt?: Nuxt): Promise<boolean
|
|
94
|
+
function hasNuxtCompatibility (constraints: NuxtCompatibility, nuxt?: Nuxt): Promise<boolean>
|
|
95
95
|
```
|
|
96
96
|
|
|
97
97
|
### Parameters
|
|
98
98
|
|
|
99
|
-
**`constraints`**: Version and builder constraints to check against. Refer to the [constraints table in `checkNuxtCompatibility`](#parameters) for details.
|
|
99
|
+
**`constraints`**: Version and builder constraints to check against. Refer to the [constraints table in `checkNuxtCompatibility`](/docs/4.x/api/kit/compatibility#parameters) for details.
|
|
100
100
|
|
|
101
101
|
**`nuxt`**: Nuxt instance. If not provided, it will be retrieved from the context via `useNuxt()` call.
|
|
102
102
|
|
|
@@ -110,20 +110,20 @@ Check if current Nuxt instance is of specified major version
|
|
|
110
110
|
import { defineNuxtModule, isNuxtMajorVersion } from '@nuxt/kit'
|
|
111
111
|
|
|
112
112
|
export default defineNuxtModule({
|
|
113
|
-
|
|
113
|
+
setup () {
|
|
114
114
|
if (isNuxtMajorVersion(3)) {
|
|
115
115
|
// do something for Nuxt 3
|
|
116
116
|
} else {
|
|
117
117
|
// do something else for other versions
|
|
118
118
|
}
|
|
119
|
-
}
|
|
119
|
+
},
|
|
120
120
|
})
|
|
121
121
|
```
|
|
122
122
|
|
|
123
123
|
### Type
|
|
124
124
|
|
|
125
125
|
```ts
|
|
126
|
-
function isNuxtMajorVersion(major: number, nuxt?: Nuxt): boolean
|
|
126
|
+
function isNuxtMajorVersion (major: number, nuxt?: Nuxt): boolean
|
|
127
127
|
```
|
|
128
128
|
|
|
129
129
|
### Parameters
|
|
@@ -143,7 +143,7 @@ Use `isNuxtMajorVersion(2, nuxt)` instead. This may be removed in \@nuxt/kit v5
|
|
|
143
143
|
### Type
|
|
144
144
|
|
|
145
145
|
```ts
|
|
146
|
-
function isNuxt3(nuxt?: Nuxt): boolean
|
|
146
|
+
function isNuxt3 (nuxt?: Nuxt): boolean
|
|
147
147
|
```
|
|
148
148
|
|
|
149
149
|
### Parameters
|
|
@@ -161,7 +161,7 @@ Use `isNuxtMajorVersion(2, nuxt)` instead. This may be removed in \@nuxt/kit v5
|
|
|
161
161
|
### Type
|
|
162
162
|
|
|
163
163
|
```ts
|
|
164
|
-
function isNuxt2(nuxt?: Nuxt): boolean
|
|
164
|
+
function isNuxt2 (nuxt?: Nuxt): boolean
|
|
165
165
|
```
|
|
166
166
|
|
|
167
167
|
### Parameters
|
|
@@ -175,7 +175,7 @@ Returns the current Nuxt version.
|
|
|
175
175
|
### Type
|
|
176
176
|
|
|
177
177
|
```ts
|
|
178
|
-
function getNuxtVersion(nuxt?: Nuxt): string
|
|
178
|
+
function getNuxtVersion (nuxt?: Nuxt): string
|
|
179
179
|
```
|
|
180
180
|
|
|
181
181
|
### Parameters
|
|
@@ -15,7 +15,7 @@ With Nuxt Kit you can also add your own auto-imports. `addImports` and `addImpor
|
|
|
15
15
|
These utilities are powered by [`unimport`](https://github.com/unjs/unimport), which provides the underlying auto-import mechanism used in Nuxt.
|
|
16
16
|
|
|
17
17
|
::note
|
|
18
|
-
These functions are designed for registering your own utils, composables and Vue APIs. For pages, components and plugins, please refer to the specific sections: [Pages](/docs/api/kit/pages), [Components](/docs/api/kit/components), [Plugins](/docs/api/kit/plugins).
|
|
18
|
+
These functions are designed for registering your own utils, composables and Vue APIs. For pages, components and plugins, please refer to the specific sections: [Pages](/docs/4.x/api/kit/pages), [Components](/docs/4.x/api/kit/components), [Plugins](/docs/4.x/api/kit/plugins).
|
|
19
19
|
::
|
|
20
20
|
|
|
21
21
|
::tip{icon="i-lucide-video" to="https://vueschool.io/lessons/expanding-nuxt-s-auto-imports?friend=nuxt" target="_blank"}
|
|
@@ -29,22 +29,22 @@ Add imports to the Nuxt application. It makes your imports available in the Nuxt
|
|
|
29
29
|
### Usage
|
|
30
30
|
|
|
31
31
|
```ts twoslash
|
|
32
|
-
import {
|
|
32
|
+
import { addImports, defineNuxtModule } from '@nuxt/kit'
|
|
33
33
|
|
|
34
34
|
export default defineNuxtModule({
|
|
35
|
-
setup(options, nuxt) {
|
|
35
|
+
setup (options, nuxt) {
|
|
36
36
|
const names = [
|
|
37
37
|
'useStoryblok',
|
|
38
38
|
'useStoryblokApi',
|
|
39
39
|
'useStoryblokBridge',
|
|
40
40
|
'renderRichText',
|
|
41
|
-
'RichTextSchema'
|
|
41
|
+
'RichTextSchema',
|
|
42
42
|
]
|
|
43
43
|
|
|
44
|
-
names.forEach(
|
|
45
|
-
addImports({ name, as: name, from: '@storyblok/vue' })
|
|
44
|
+
names.forEach(name =>
|
|
45
|
+
addImports({ name, as: name, from: '@storyblok/vue' }),
|
|
46
46
|
)
|
|
47
|
-
}
|
|
47
|
+
},
|
|
48
48
|
})
|
|
49
49
|
```
|
|
50
50
|
|
|
@@ -76,14 +76,14 @@ Add imports from a directory to the Nuxt application. It will automatically impo
|
|
|
76
76
|
### Usage
|
|
77
77
|
|
|
78
78
|
```ts twoslash
|
|
79
|
-
import {
|
|
79
|
+
import { addImportsDir, createResolver, defineNuxtModule } from '@nuxt/kit'
|
|
80
80
|
|
|
81
81
|
export default defineNuxtModule({
|
|
82
82
|
meta: {
|
|
83
83
|
name: '@vueuse/motion',
|
|
84
84
|
configKey: 'motion',
|
|
85
85
|
},
|
|
86
|
-
setup(options, nuxt) {
|
|
86
|
+
setup (options, nuxt) {
|
|
87
87
|
const resolver = createResolver(import.meta.url)
|
|
88
88
|
addImportsDir(resolver.resolve('./runtime/composables'))
|
|
89
89
|
},
|
|
@@ -110,10 +110,10 @@ Add listed imports to the Nuxt application.
|
|
|
110
110
|
### Usage
|
|
111
111
|
|
|
112
112
|
```ts twoslash
|
|
113
|
-
import {
|
|
113
|
+
import { addImportsSources, defineNuxtModule } from '@nuxt/kit'
|
|
114
114
|
|
|
115
115
|
export default defineNuxtModule({
|
|
116
|
-
setup() {
|
|
116
|
+
setup () {
|
|
117
117
|
addImportsSources({
|
|
118
118
|
from: 'h3',
|
|
119
119
|
imports: [
|
|
@@ -121,10 +121,10 @@ export default defineNuxtModule({
|
|
|
121
121
|
'getQuery',
|
|
122
122
|
'getRouterParams',
|
|
123
123
|
'readBody',
|
|
124
|
-
'sendRedirect'
|
|
124
|
+
'sendRedirect',
|
|
125
125
|
],
|
|
126
126
|
})
|
|
127
|
-
}
|
|
127
|
+
},
|
|
128
128
|
})
|
|
129
129
|
```
|
|
130
130
|
|
|
@@ -26,13 +26,13 @@ export default defineNuxtModule({
|
|
|
26
26
|
name: '@nuxt/ui',
|
|
27
27
|
configKey: 'ui',
|
|
28
28
|
},
|
|
29
|
-
setup() {
|
|
29
|
+
setup () {
|
|
30
30
|
addComponentsDir({
|
|
31
31
|
path: resolve('./runtime/components'),
|
|
32
32
|
prefix: 'U',
|
|
33
|
-
pathPrefix: false
|
|
33
|
+
pathPrefix: false,
|
|
34
34
|
})
|
|
35
|
-
}
|
|
35
|
+
},
|
|
36
36
|
})
|
|
37
37
|
```
|
|
38
38
|
|
|
@@ -58,7 +58,7 @@ function addComponentsDir (dir: ComponentsDir, opts: { prepend?: boolean } = {})
|
|
|
58
58
|
| `isAsync` | `boolean` | `false` | This flag indicates, component should be loaded async (with a separate chunk) regardless of using Lazy prefix or not. |
|
|
59
59
|
| `extendComponent` | `(component: Component) => Promise<Component \| void> \| (Component \| void)`{lang="ts"} | `false` | A function that will be called for each component found in the directory. It accepts a component object and should return a component object or a promise that resolves to a component object. |
|
|
60
60
|
| `global` | `boolean` | `false` | If enabled, registers components to be globally available. |
|
|
61
|
-
| `island` | `boolean` | `false` | If enabled, registers components as islands. You can read more about islands in [`<NuxtIsland/>`](/docs/api/components/nuxt-island
|
|
61
|
+
| `island` | `boolean` | `false` | If enabled, registers components as islands. You can read more about islands in [`<NuxtIsland/>`](/docs/4.x/api/components/nuxt-island) component description. |
|
|
62
62
|
| `watch` | `boolean` | `false` | Watch specified path for changes, including file additions and file deletions. |
|
|
63
63
|
| `extensions` | `string[]` | `false` | Extensions supported by Nuxt builder. |
|
|
64
64
|
| `transpile` | `'auto' \| boolean`{lang="ts"} | `false` | Transpile specified path using build.transpile. If set to `'auto'`, it will set `transpile: true` if `node_modules/` is in path. |
|
|
@@ -76,14 +76,14 @@ Register a component to be automatically imported.
|
|
|
76
76
|
### Usage
|
|
77
77
|
|
|
78
78
|
```ts
|
|
79
|
-
import {
|
|
79
|
+
import { addComponent, createResolver, defineNuxtModule } from '@nuxt/kit'
|
|
80
80
|
|
|
81
81
|
export default defineNuxtModule({
|
|
82
82
|
meta: {
|
|
83
83
|
name: '@nuxt/image',
|
|
84
84
|
configKey: 'image',
|
|
85
85
|
},
|
|
86
|
-
|
|
86
|
+
setup () {
|
|
87
87
|
const resolver = createResolver(import.meta.url)
|
|
88
88
|
|
|
89
89
|
addComponent({
|
|
@@ -113,6 +113,7 @@ function addComponent (options: AddComponentOptions): void
|
|
|
113
113
|
| ------------------ | ---------------------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
|
|
114
114
|
| `name` | `string` | `true` | Component name. |
|
|
115
115
|
| `filePath` | `string` | `true` | Path to the component. |
|
|
116
|
+
| `declarationPath` | `string` | `false` | Path to component's declaration file. It is used to generate components' [type templates](/docs/4.x/api/kit/templates#addtypetemplate); if not provided, `filePath` is used instead. |
|
|
116
117
|
| `pascalName` | `string` | `false` | Pascal case component name. If not provided, it will be generated from the component name. |
|
|
117
118
|
| `kebabName` | `string` | `false` | Kebab case component name. If not provided, it will be generated from the component name. |
|
|
118
119
|
| `export` | `string` | `false` | Specify named or default export. If not provided, it will be set to `'default'`. |
|
|
@@ -121,7 +122,7 @@ function addComponent (options: AddComponentOptions): void
|
|
|
121
122
|
| `prefetch` | `boolean` | `false` | These properties (prefetch/preload) are used in production to configure how components with Lazy prefix are handled by webpack via its magic comments. Learn more on [webpack documentation](https://webpack.js.org/api/module-methods/#magic-comments) |
|
|
122
123
|
| `preload` | `boolean` | `false` | These properties (prefetch/preload) are used in production to configure how components with Lazy prefix are handled by webpack via its magic comments. Learn more on [webpack documentation](https://webpack.js.org/api/module-methods/#magic-comments) |
|
|
123
124
|
| `global` | `boolean` | `false` | If enabled, registers component to be globally available. |
|
|
124
|
-
| `island` | `boolean` | `false` | If enabled, registers component as island. You can read more about islands in [`<NuxtIsland/>`](/docs/api/components/nuxt-island
|
|
125
|
+
| `island` | `boolean` | `false` | If enabled, registers component as island. You can read more about islands in [`<NuxtIsland/>`](/docs/4.x/api/components/nuxt-island) component description. |
|
|
125
126
|
| `mode` | `'client' \| 'server' \| 'all'`{lang="ts"} | `false` | This options indicates if component should render on client, server or both. By default, it will render on both client and server. |
|
|
126
127
|
| `priority` | `number` | `false` | Priority of the component, if multiple components have the same name, the one with the highest priority will be used. |
|
|
127
128
|
|
package/3.api/5.kit/6.context.md
CHANGED
|
@@ -37,7 +37,7 @@ const setupSomeFeature = () => {
|
|
|
37
37
|
// @errors: 2391
|
|
38
38
|
import type { Nuxt } from '@nuxt/schema'
|
|
39
39
|
// ---cut---
|
|
40
|
-
function useNuxt(): Nuxt
|
|
40
|
+
function useNuxt (): Nuxt
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
### Return Value
|
|
@@ -114,7 +114,7 @@ function setupSomething () {
|
|
|
114
114
|
// @errors: 2391
|
|
115
115
|
import type { Nuxt } from '@nuxt/schema'
|
|
116
116
|
// ---cut---
|
|
117
|
-
function tryUseNuxt(): Nuxt | null
|
|
117
|
+
function tryUseNuxt (): Nuxt | null
|
|
118
118
|
```
|
|
119
119
|
|
|
120
120
|
### Return Value
|
|
@@ -156,7 +156,7 @@ interface SiteConfig {
|
|
|
156
156
|
title?: string
|
|
157
157
|
}
|
|
158
158
|
export const requireSiteConfig = (): SiteConfig => {
|
|
159
|
-
|
|
159
|
+
return {}
|
|
160
160
|
}
|
|
161
161
|
// @filename: module.ts
|
|
162
162
|
// ---cut---
|
package/3.api/5.kit/7.pages.md
CHANGED
|
@@ -39,7 +39,7 @@ export default defineNuxtModule({
|
|
|
39
39
|
### Type
|
|
40
40
|
|
|
41
41
|
```ts
|
|
42
|
-
function extendPages(callback: (pages: NuxtPage[]) => void): void
|
|
42
|
+
function extendPages (callback: (pages: NuxtPage[]) => void): void
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
### Parameters
|
|
@@ -104,7 +104,7 @@ export default defineNuxtModule({
|
|
|
104
104
|
### Type
|
|
105
105
|
|
|
106
106
|
```ts
|
|
107
|
-
function extendRouteRules(route: string, rule: NitroRouteConfig, options?: ExtendRouteRulesOptions): void
|
|
107
|
+
function extendRouteRules (route: string, rule: NitroRouteConfig, options?: ExtendRouteRulesOptions): void
|
|
108
108
|
```
|
|
109
109
|
|
|
110
110
|
### Parameters
|
|
@@ -113,7 +113,7 @@ function extendRouteRules(route: string, rule: NitroRouteConfig, options?: Exten
|
|
|
113
113
|
**rule**: A route rule configuration to apply to the matched route.
|
|
114
114
|
|
|
115
115
|
::tip
|
|
116
|
-
About route rules configurations, you can get more detail in [Hybrid Rendering > Route Rules](/docs/guide/concepts/rendering#route-rules).
|
|
116
|
+
About route rules configurations, you can get more detail in [Hybrid Rendering > Route Rules](/docs/4.x/guide/concepts/rendering#route-rules).
|
|
117
117
|
::
|
|
118
118
|
|
|
119
119
|
**options**: A object to pass to the route configuration. If `override` is set to `true`, it will override the existing route configuration.
|
|
@@ -126,10 +126,10 @@ About route rules configurations, you can get more detail in [Hybrid Rendering >
|
|
|
126
126
|
|
|
127
127
|
Registers route middlewares to be available for all routes or for specific routes.
|
|
128
128
|
|
|
129
|
-
Route middlewares can be also defined in plugins via [`addRouteMiddleware`](/docs/api/utils/add-route-middleware) composable.
|
|
129
|
+
Route middlewares can be also defined in plugins via [`addRouteMiddleware`](/docs/4.x/api/utils/add-route-middleware) composable.
|
|
130
130
|
|
|
131
131
|
::tip
|
|
132
|
-
Read more about route middlewares in the [Route middleware documentation](/docs/getting-started/routing#route-middleware).
|
|
132
|
+
Read more about route middlewares in the [Route middleware documentation](/docs/4.x/getting-started/routing#route-middleware).
|
|
133
133
|
::
|
|
134
134
|
|
|
135
135
|
::tip{icon="i-lucide-video" to="https://vueschool.io/lessons/adding-route-rules-and-route-middlewares?friend=nuxt" target="_blank"}
|
|
@@ -157,7 +157,7 @@ export default defineNuxtModule({
|
|
|
157
157
|
```
|
|
158
158
|
|
|
159
159
|
```ts twoslash [runtime/auth.ts]
|
|
160
|
-
function isAuthenticated(): boolean { return false }
|
|
160
|
+
function isAuthenticated (): boolean { return false }
|
|
161
161
|
// ---cut---
|
|
162
162
|
export default defineNuxtRouteMiddleware((to, from) => {
|
|
163
163
|
// isAuthenticated() is an example method verifying if a user is authenticated
|
|
@@ -172,7 +172,7 @@ export default defineNuxtRouteMiddleware((to, from) => {
|
|
|
172
172
|
### Type
|
|
173
173
|
|
|
174
174
|
```ts
|
|
175
|
-
function addRouteMiddleware(input: NuxtMiddleware | NuxtMiddleware[], options?: AddRouteMiddlewareOptions): void
|
|
175
|
+
function addRouteMiddleware (input: NuxtMiddleware | NuxtMiddleware[], options?: AddRouteMiddlewareOptions): void
|
|
176
176
|
```
|
|
177
177
|
|
|
178
178
|
### Parameters
|
package/3.api/5.kit/8.layout.md
CHANGED
|
@@ -15,7 +15,7 @@ Layouts is used to be a wrapper around your pages. It can be used to wrap your p
|
|
|
15
15
|
Register template as layout and add it to the layouts.
|
|
16
16
|
|
|
17
17
|
::note
|
|
18
|
-
In Nuxt 2 `error` layout can also be registered using this utility. In Nuxt 3+ `error` layout [replaced](/docs/getting-started/error-handling#
|
|
18
|
+
In Nuxt 2 `error` layout can also be registered using this utility. In Nuxt 3+ `error` layout [replaced](/docs/4.x/getting-started/error-handling#error-page) with `error.vue` page in project root.
|
|
19
19
|
::
|
|
20
20
|
|
|
21
21
|
### Usage
|
|
@@ -38,7 +38,7 @@ export default defineNuxtModule({
|
|
|
38
38
|
### Type
|
|
39
39
|
|
|
40
40
|
```ts
|
|
41
|
-
function addLayout(layout: NuxtTemplate | string, name: string): void
|
|
41
|
+
function addLayout (layout: NuxtTemplate | string, name: string): void
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
### Parameters
|