@nuxt/docs 3.20.0 → 3.20.2
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 +1 -1
- package/1.getting-started/02.installation.md +2 -2
- package/1.getting-started/03.configuration.md +3 -3
- package/1.getting-started/04.views.md +5 -5
- package/1.getting-started/05.assets.md +7 -7
- package/1.getting-started/06.styling.md +3 -3
- package/1.getting-started/07.routing.md +8 -4
- package/1.getting-started/08.seo-meta.md +2 -2
- package/1.getting-started/09.transitions.md +6 -6
- package/1.getting-started/10.data-fetching.md +12 -12
- package/1.getting-started/11.state-management.md +2 -2
- package/1.getting-started/12.error-handling.md +3 -3
- package/1.getting-started/14.layers.md +31 -12
- package/1.getting-started/16.deployment.md +1 -1
- package/1.getting-started/17.testing.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/0.nuxt.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/0.output.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.assets.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.components.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.composables.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.content.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.layouts.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.middleware.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.modules.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.node_modules.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.pages.md +6 -6
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.plugins.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.server.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.shared.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.utils.md +3 -3
- package/{2.guide/1.directory-structure → 2.directory-structure}/2.env.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/2.nuxtignore.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/2.nuxtrc.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/3.app.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/3.error.md +1 -3
- package/{2.guide/1.directory-structure → 2.directory-structure}/3.nuxt-config.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/3.tsconfig.md +23 -0
- package/2.directory-structure/index.md +61 -0
- package/{2.guide → 3.guide}/0.index.md +6 -9
- package/{2.guide/2.concepts → 3.guide/1.concepts}/1.auto-imports.md +4 -4
- package/{2.guide/2.concepts → 3.guide/1.concepts}/10.nuxt-lifecycle.md +3 -3
- package/{2.guide/2.concepts → 3.guide/1.concepts}/2.vuejs-development.md +3 -3
- package/{2.guide/2.concepts → 3.guide/1.concepts}/3.rendering.md +1 -1
- package/{2.guide/2.concepts → 3.guide/1.concepts}/4.server-engine.md +2 -2
- package/{2.guide/2.concepts → 3.guide/1.concepts}/5.modules.md +1 -1
- package/{2.guide/2.concepts → 3.guide/1.concepts}/8.typescript.md +2 -2
- package/{2.guide/2.concepts → 3.guide/1.concepts}/9.code-style.md +1 -1
- package/{2.guide/4.recipes → 3.guide/3.recipes}/1.custom-routing.md +1 -1
- package/{2.guide/4.recipes → 3.guide/3.recipes}/2.vite-plugin.md +3 -3
- package/{2.guide/4.recipes → 3.guide/3.recipes}/3.custom-usefetch.md +1 -1
- package/{2.guide/3.going-further → 3.guide/4.going-further}/1.experimental-features.md +6 -6
- package/{2.guide/3.going-further → 3.guide/4.going-further}/1.internals.md +2 -2
- package/{2.guide/3.going-further → 3.guide/4.going-further}/10.runtime-config.md +1 -1
- package/{2.guide/3.going-further → 3.guide/4.going-further}/2.hooks.md +2 -2
- package/{2.guide/3.going-further → 3.guide/4.going-further}/3.modules.md +3 -3
- package/{2.guide/3.going-further → 3.guide/4.going-further}/6.nuxt-app.md +1 -1
- package/{2.guide/3.going-further → 3.guide/4.going-further}/7.layers.md +41 -24
- package/{3.api → 4.api}/1.components/12.nuxt-route-announcer.md +1 -1
- package/{3.api → 4.api}/1.components/2.nuxt-page.md +1 -1
- package/{3.api → 4.api}/1.components/3.nuxt-layout.md +2 -2
- package/{3.api → 4.api}/1.components/5.nuxt-loading-indicator.md +1 -1
- package/{3.api → 4.api}/2.composables/use-async-data.md +76 -13
- package/{3.api → 4.api}/2.composables/use-cookie.md +1 -1
- package/{3.api → 4.api}/2.composables/use-fetch.md +1 -1
- package/{3.api → 4.api}/2.composables/use-head-safe.md +37 -20
- package/4.api/2.composables/use-head.md +169 -0
- package/{3.api → 4.api}/2.composables/use-hydration.md +24 -18
- package/4.api/2.composables/use-lazy-async-data.md +96 -0
- package/4.api/2.composables/use-lazy-fetch.md +111 -0
- package/{3.api → 4.api}/2.composables/use-nuxt-app.md +5 -5
- package/{3.api → 4.api}/2.composables/use-nuxt-data.md +1 -1
- package/{3.api → 4.api}/2.composables/use-request-fetch.md +1 -1
- package/{3.api → 4.api}/2.composables/use-response-header.md +1 -1
- package/{3.api → 4.api}/2.composables/use-route.md +1 -1
- package/{3.api → 4.api}/2.composables/use-router.md +1 -1
- package/{3.api → 4.api}/2.composables/use-runtime-hook.md +1 -1
- package/{3.api → 4.api}/3.utils/$fetch.md +1 -1
- package/{3.api → 4.api}/3.utils/abort-navigation.md +1 -1
- package/{3.api → 4.api}/3.utils/add-route-middleware.md +1 -1
- package/{3.api → 4.api}/3.utils/define-nuxt-plugin.md +1 -1
- package/{3.api → 4.api}/3.utils/define-nuxt-route-middleware.md +1 -1
- package/{3.api → 4.api}/3.utils/define-page-meta.md +5 -5
- package/{3.api → 4.api}/3.utils/navigate-to.md +1 -1
- package/{3.api → 4.api}/3.utils/refresh-cookie.md +2 -2
- package/{3.api → 4.api}/3.utils/update-app-config.md +1 -1
- package/{3.api → 4.api}/4.commands/module.md +2 -2
- package/{3.api → 4.api}/4.commands/prepare.md +1 -1
- package/{3.api → 4.api}/4.commands/preview.md +1 -1
- package/{3.api → 4.api}/4.commands/typecheck.md +1 -1
- package/{3.api → 4.api}/5.kit/1.modules.md +1 -1
- package/{3.api → 4.api}/5.kit/2.programmatic.md +2 -2
- package/{3.api → 4.api}/5.kit/5.components.md +1 -1
- package/{3.api → 4.api}/6.advanced/1.hooks.md +1 -1
- package/5.community/3.reporting-bugs.md +1 -1
- package/5.community/6.roadmap.md +6 -6
- package/5.community/7.changelog.md +10 -0
- package/6.bridge/1.overview.md +1 -1
- package/6.bridge/4.plugins-and-middleware.md +2 -2
- package/7.migration/2.configuration.md +1 -1
- package/7.migration/3.auto-imports.md +1 -1
- package/7.migration/6.pages-and-layouts.md +4 -4
- package/package.json +1 -1
- package/3.api/2.composables/use-head.md +0 -69
- package/3.api/2.composables/use-lazy-async-data.md +0 -47
- package/3.api/2.composables/use-lazy-fetch.md +0 -55
- /package/{2.guide/1.directory-structure → 2.directory-structure}/.navigation.yml +0 -0
- /package/{2.guide/1.directory-structure → 2.directory-structure}/1.public.md +0 -0
- /package/{2.guide/1.directory-structure → 2.directory-structure}/2.gitignore.md +0 -0
- /package/{2.guide/1.directory-structure → 2.directory-structure}/3.app-config.md +0 -0
- /package/{2.guide/1.directory-structure → 2.directory-structure}/3.package.md +0 -0
- /package/{2.guide → 3.guide}/.navigation.yml +0 -0
- /package/{2.guide/2.concepts → 3.guide/1.concepts}/.navigation.yml +0 -0
- /package/{2.guide/2.concepts → 3.guide/1.concepts}/7.esm.md +0 -0
- /package/{2.guide/5.best-practices → 3.guide/2.best-practices}/.navigation.yml +0 -0
- /package/{2.guide/5.best-practices → 3.guide/2.best-practices}/hydration.md +0 -0
- /package/{2.guide/5.best-practices → 3.guide/2.best-practices}/performance.md +0 -0
- /package/{2.guide/5.best-practices → 3.guide/2.best-practices}/plugins.md +0 -0
- /package/{2.guide/4.recipes → 3.guide/3.recipes}/.navigation.yml +0 -0
- /package/{2.guide/4.recipes → 3.guide/3.recipes}/4.sessions-and-authentication.md +0 -0
- /package/{2.guide/3.going-further → 3.guide/4.going-further}/.navigation.yml +0 -0
- /package/{2.guide/3.going-further → 3.guide/4.going-further}/1.events.md +0 -0
- /package/{2.guide/3.going-further → 3.guide/4.going-further}/1.features.md +0 -0
- /package/{2.guide/3.going-further → 3.guide/4.going-further}/11.nightly-release-channel.md +0 -0
- /package/{2.guide/3.going-further → 3.guide/4.going-further}/4.kit.md +0 -0
- /package/{2.guide/3.going-further → 3.guide/4.going-further}/9.debugging.md +0 -0
- /package/{2.guide/3.going-further → 3.guide/4.going-further}/index.md +0 -0
- /package/{3.api → 4.api}/.navigation.yml +0 -0
- /package/{3.api → 4.api}/1.components/.navigation.yml +0 -0
- /package/{3.api → 4.api}/1.components/1.client-only.md +0 -0
- /package/{3.api → 4.api}/1.components/1.dev-only.md +0 -0
- /package/{3.api → 4.api}/1.components/1.nuxt-client-fallback.md +0 -0
- /package/{3.api → 4.api}/1.components/10.nuxt-picture.md +0 -0
- /package/{3.api → 4.api}/1.components/11.teleports.md +0 -0
- /package/{3.api → 4.api}/1.components/13.nuxt-time.md +0 -0
- /package/{3.api → 4.api}/1.components/4.nuxt-link.md +0 -0
- /package/{3.api → 4.api}/1.components/6.nuxt-error-boundary.md +0 -0
- /package/{3.api → 4.api}/1.components/7.nuxt-welcome.md +0 -0
- /package/{3.api → 4.api}/1.components/8.nuxt-island.md +0 -0
- /package/{3.api → 4.api}/1.components/9.nuxt-img.md +0 -0
- /package/{3.api → 4.api}/2.composables/.navigation.yml +0 -0
- /package/{3.api → 4.api}/2.composables/on-prehydrate.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-app-config.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-error.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-loading-indicator.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-preview-mode.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-request-event.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-request-header.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-request-headers.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-request-url.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-route-announcer.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-runtime-config.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-seo-meta.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-server-seo-meta.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-state.md +0 -0
- /package/{3.api → 4.api}/3.utils/.navigation.yml +0 -0
- /package/{3.api → 4.api}/3.utils/call-once.md +0 -0
- /package/{3.api → 4.api}/3.utils/clear-error.md +0 -0
- /package/{3.api → 4.api}/3.utils/clear-nuxt-data.md +0 -0
- /package/{3.api → 4.api}/3.utils/clear-nuxt-state.md +0 -0
- /package/{3.api → 4.api}/3.utils/create-error.md +0 -0
- /package/{3.api → 4.api}/3.utils/define-lazy-hydration-component.md +0 -0
- /package/{3.api → 4.api}/3.utils/define-nuxt-component.md +0 -0
- /package/{3.api → 4.api}/3.utils/define-route-rules.md +0 -0
- /package/{3.api → 4.api}/3.utils/on-before-route-leave.md +0 -0
- /package/{3.api → 4.api}/3.utils/on-before-route-update.md +0 -0
- /package/{3.api → 4.api}/3.utils/on-nuxt-ready.md +0 -0
- /package/{3.api → 4.api}/3.utils/prefetch-components.md +0 -0
- /package/{3.api → 4.api}/3.utils/preload-components.md +0 -0
- /package/{3.api → 4.api}/3.utils/preload-route-components.md +0 -0
- /package/{3.api → 4.api}/3.utils/prerender-routes.md +0 -0
- /package/{3.api → 4.api}/3.utils/refresh-nuxt-data.md +0 -0
- /package/{3.api → 4.api}/3.utils/reload-nuxt-app.md +0 -0
- /package/{3.api → 4.api}/3.utils/set-page-layout.md +0 -0
- /package/{3.api → 4.api}/3.utils/set-response-status.md +0 -0
- /package/{3.api → 4.api}/3.utils/show-error.md +0 -0
- /package/{3.api → 4.api}/4.commands/.navigation.yml +0 -0
- /package/{3.api → 4.api}/4.commands/add.md +0 -0
- /package/{3.api → 4.api}/4.commands/analyze.md +0 -0
- /package/{3.api → 4.api}/4.commands/build-module.md +0 -0
- /package/{3.api → 4.api}/4.commands/build.md +0 -0
- /package/{3.api → 4.api}/4.commands/cleanup.md +0 -0
- /package/{3.api → 4.api}/4.commands/dev.md +0 -0
- /package/{3.api → 4.api}/4.commands/devtools.md +0 -0
- /package/{3.api → 4.api}/4.commands/generate.md +0 -0
- /package/{3.api → 4.api}/4.commands/info.md +0 -0
- /package/{3.api → 4.api}/4.commands/init.md +0 -0
- /package/{3.api → 4.api}/4.commands/test.md +0 -0
- /package/{3.api → 4.api}/4.commands/upgrade.md +0 -0
- /package/{3.api → 4.api}/5.kit/.navigation.yml +0 -0
- /package/{3.api → 4.api}/5.kit/10.runtime-config.md +0 -0
- /package/{3.api → 4.api}/5.kit/10.templates.md +0 -0
- /package/{3.api → 4.api}/5.kit/11.nitro.md +0 -0
- /package/{3.api → 4.api}/5.kit/12.resolving.md +0 -0
- /package/{3.api → 4.api}/5.kit/13.logging.md +0 -0
- /package/{3.api → 4.api}/5.kit/14.builder.md +0 -0
- /package/{3.api → 4.api}/5.kit/15.examples.md +0 -0
- /package/{3.api → 4.api}/5.kit/16.layers.md +0 -0
- /package/{3.api → 4.api}/5.kit/3.compatibility.md +0 -0
- /package/{3.api → 4.api}/5.kit/4.autoimports.md +0 -0
- /package/{3.api → 4.api}/5.kit/6.context.md +0 -0
- /package/{3.api → 4.api}/5.kit/7.pages.md +0 -0
- /package/{3.api → 4.api}/5.kit/8.layout.md +0 -0
- /package/{3.api → 4.api}/5.kit/9.head.md +0 -0
- /package/{3.api → 4.api}/5.kit/9.plugins.md +0 -0
- /package/{3.api → 4.api}/6.advanced/.navigation.yml +0 -0
- /package/{3.api → 4.api}/6.advanced/2.import-meta.md +0 -0
- /package/{3.api → 4.api}/6.nuxt-config.md +0 -0
- /package/{3.api → 4.api}/index.md +0 -0
package/5.community/6.roadmap.md
CHANGED
|
@@ -38,12 +38,12 @@ Translations | - | [nuxt/translations#4](https://github.com/nuxt/tra
|
|
|
38
38
|
|
|
39
39
|
In addition to the Nuxt framework, there are modules that are vital for the ecosystem. Their status will be updated below.
|
|
40
40
|
|
|
41
|
-
Module
|
|
42
|
-
|
|
43
|
-
[Scripts](https://scripts.nuxt.com)
|
|
44
|
-
Auth Utils
|
|
45
|
-
A11y
|
|
46
|
-
Hints
|
|
41
|
+
Module | Status | Nuxt Support | Repository | Description
|
|
42
|
+
---------------------------------------|---------------------|--------------|------------|-------------------
|
|
43
|
+
[Scripts](https://scripts.nuxt.com) | Public Beta | 3.x, 4.x | [nuxt/scripts](https://github.com/nuxt/scripts) | Easy 3rd party script management.
|
|
44
|
+
Auth Utils | Planned | 4.x, 5.x | `nuxt/auth-utils` to be announced | The temporary repository [atinux/nuxt-auth-utils](https://github.com/atinux/nuxt-auth-utils) is available while awaiting its official integration into Nuxt via RFC.
|
|
45
|
+
A11y | Planned | 4.x, 5.x | `nuxt/a11y` to be announced | Accessibility hinting and utilities [nuxt/nuxt#23255](https://github.com/nuxt/nuxt/issues/23255)
|
|
46
|
+
[Hints](https://github.com/nuxt/hints) | Public Alpha | 4.x, 5.x | [nuxt/hints](https://github.com/nuxt/hints) | Guidance and suggestions for enhancing development practices.
|
|
47
47
|
|
|
48
48
|
## Release Cycle
|
|
49
49
|
|
|
@@ -58,6 +58,16 @@ navigation.icon: i-lucide-bell-dot
|
|
|
58
58
|
::card
|
|
59
59
|
---
|
|
60
60
|
icon: i-simple-icons-github
|
|
61
|
+
title: nuxt/hints
|
|
62
|
+
to: https://github.com/nuxt/hints/releases
|
|
63
|
+
target: _blank
|
|
64
|
+
ui.icon.base: text-black dark:text-white
|
|
65
|
+
---
|
|
66
|
+
Nuxt Hints releases.
|
|
67
|
+
::
|
|
68
|
+
::card
|
|
69
|
+
---
|
|
70
|
+
icon: i-simple-icons-github
|
|
61
71
|
title: nuxt/image
|
|
62
72
|
to: https://github.com/nuxt/image/releases
|
|
63
73
|
target: _blank
|
package/6.bridge/1.overview.md
CHANGED
|
@@ -80,7 +80,7 @@ bun add -D @nuxt/bridge nuxi
|
|
|
80
80
|
|
|
81
81
|
Please make sure to avoid any CommonJS syntax such as `module.exports`, `require` or `require.resolve` in your config file. It will soon be deprecated and unsupported.
|
|
82
82
|
|
|
83
|
-
You can use static `import`, dynamic `import()` and `export default` instead. Using TypeScript by renaming to [`nuxt.config.ts`](/docs/3.x/
|
|
83
|
+
You can use static `import`, dynamic `import()` and `export default` instead. Using TypeScript by renaming to [`nuxt.config.ts`](/docs/3.x/directory-structure/nuxt-config) is also possible and recommended.
|
|
84
84
|
|
|
85
85
|
```ts [nuxt.config.ts]
|
|
86
86
|
import { defineNuxtConfig } from '@nuxt/bridge'
|
|
@@ -7,7 +7,7 @@ description: 'Learn how to migrate from Nuxt 2 to Nuxt Bridge new plugins and mi
|
|
|
7
7
|
|
|
8
8
|
You can now migrate to the Nuxt 3 plugins API, which is slightly different in format from Nuxt 2.
|
|
9
9
|
|
|
10
|
-
Plugins now take only one argument (`nuxtApp`). You can find out more in [the docs](/docs/3.x/
|
|
10
|
+
Plugins now take only one argument (`nuxtApp`). You can find out more in [the docs](/docs/3.x/directory-structure/plugins).
|
|
11
11
|
|
|
12
12
|
```ts [plugins/hello.ts]
|
|
13
13
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
@@ -28,7 +28,7 @@ Although a compatibility interface is provided via `nuxtApp.vueApp` you should a
|
|
|
28
28
|
|
|
29
29
|
You can now migrate to the Nuxt 3 middleware API, which is slightly different in format from Nuxt 2.
|
|
30
30
|
|
|
31
|
-
Middleware now take only two argument (`to`, `from`). You can find out more in [the docs](/docs/3.x/
|
|
31
|
+
Middleware now take only two argument (`to`, `from`). You can find out more in [the docs](/docs/3.x/directory-structure/middleware).
|
|
32
32
|
|
|
33
33
|
```ts twoslash
|
|
34
34
|
export default defineNuxtRouteMiddleware((to) => {
|
|
@@ -213,7 +213,7 @@ export const useMainStore = defineStore('main', {
|
|
|
213
213
|
})
|
|
214
214
|
```
|
|
215
215
|
|
|
216
|
-
Create a [plugin](/docs/3.x/
|
|
216
|
+
Create a [plugin](/docs/3.x/directory-structure/plugins) file to globalize your store:
|
|
217
217
|
|
|
218
218
|
```ts [plugins/pinia.ts]
|
|
219
219
|
import { useMainStore } from '~/store'
|
|
@@ -11,7 +11,7 @@ In the rest of the migration documentation, you will notice that key Nuxt and Vu
|
|
|
11
11
|
|
|
12
12
|
## Migration
|
|
13
13
|
|
|
14
|
-
1. If you have been using `@nuxt/components` in Nuxt 2, you can remove `components: true` in your `nuxt.config`. If you had a more complex setup, then note that the component options have changed somewhat. See the [components documentation](/docs/3.x/
|
|
14
|
+
1. If you have been using `@nuxt/components` in Nuxt 2, you can remove `components: true` in your `nuxt.config`. If you had a more complex setup, then note that the component options have changed somewhat. See the [components documentation](/docs/3.x/directory-structure/components) for more information.
|
|
15
15
|
|
|
16
16
|
::tip
|
|
17
17
|
You can look at `.nuxt/types/components.d.ts` and `.nuxt/types/imports.d.ts` to see how Nuxt has resolved your components and composable auto-imports.
|
|
@@ -19,13 +19,13 @@ This file is a great place to put any custom code that needs to be run once when
|
|
|
19
19
|
|
|
20
20
|
### Migration
|
|
21
21
|
|
|
22
|
-
Consider creating an `app.vue` file and including any logic that needs to run once at the top-level of your app. You can check out [an example here](/docs/3.x/
|
|
22
|
+
Consider creating an `app.vue` file and including any logic that needs to run once at the top-level of your app. You can check out [an example here](/docs/3.x/directory-structure/app).
|
|
23
23
|
|
|
24
24
|
## Layouts
|
|
25
25
|
|
|
26
26
|
If you are using layouts in your app for multiple pages, there is only a slight change required.
|
|
27
27
|
|
|
28
|
-
In Nuxt 2, the `<Nuxt>` component is used within a layout to render the current page. In Nuxt 3, layouts use slots instead, so you will have to replace that component with a `<slot />`. This also allows advanced use cases with named and scoped slots. [Read more about layouts](/docs/3.x/
|
|
28
|
+
In Nuxt 2, the `<Nuxt>` component is used within a layout to render the current page. In Nuxt 3, layouts use slots instead, so you will have to replace that component with a `<slot />`. This also allows advanced use cases with named and scoped slots. [Read more about layouts](/docs/3.x/directory-structure/layouts).
|
|
29
29
|
|
|
30
30
|
You will also need to change how you define the layout used by a page using the `definePageMeta` compiler macro. Layouts will be kebab-cased. So `layouts/customLayout.vue` becomes `custom-layout` when referenced in your page.
|
|
31
31
|
|
|
@@ -54,7 +54,7 @@ You will also need to change how you define the layout used by a page using the
|
|
|
54
54
|
- }
|
|
55
55
|
</script>
|
|
56
56
|
```
|
|
57
|
-
3. Move `~/layouts/_error.vue` to `~/error.vue`. See [the error handling docs](/docs/3.x/getting-started/error-handling). If you want to ensure that this page uses a layout, you can use [`<NuxtLayout>`](/docs/3.x/
|
|
57
|
+
3. Move `~/layouts/_error.vue` to `~/error.vue`. See [the error handling docs](/docs/3.x/getting-started/error-handling). If you want to ensure that this page uses a layout, you can use [`<NuxtLayout>`](/docs/3.x/directory-structure/layouts) directly within `error.vue`:
|
|
58
58
|
```vue [error.vue]
|
|
59
59
|
<template>
|
|
60
60
|
<div>
|
|
@@ -67,7 +67,7 @@ You will also need to change how you define the layout used by a page using the
|
|
|
67
67
|
|
|
68
68
|
## Pages
|
|
69
69
|
|
|
70
|
-
Nuxt 3 ships with an optional `vue-router` integration triggered by the existence of a [`pages/`](/docs/3.x/
|
|
70
|
+
Nuxt 3 ships with an optional `vue-router` integration triggered by the existence of a [`pages/`](/docs/3.x/directory-structure/pages) directory in your source directory. If you only have a single page, you may consider instead moving it to `app.vue` for a lighter build.
|
|
71
71
|
|
|
72
72
|
### Dynamic Routes
|
|
73
73
|
|
package/package.json
CHANGED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: useHead
|
|
3
|
-
description: useHead customizes the head properties of individual pages of your Nuxt app.
|
|
4
|
-
links:
|
|
5
|
-
- label: Source
|
|
6
|
-
icon: i-simple-icons-github
|
|
7
|
-
to: https://github.com/unjs/unhead/blob/main/packages/vue/src/composables.ts
|
|
8
|
-
size: xs
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
The [`useHead`](/docs/3.x/api/composables/use-head) composable function allows you to manage your head tags in a programmatic and reactive way, powered by [Unhead](https://unhead.unjs.io). If the data comes from a user or other untrusted source, we recommend you check out [`useHeadSafe`](/docs/3.x/api/composables/use-head-safe).
|
|
12
|
-
|
|
13
|
-
:read-more{to="/docs/getting-started/seo-meta"}
|
|
14
|
-
|
|
15
|
-
## Type
|
|
16
|
-
|
|
17
|
-
```ts [Signature]
|
|
18
|
-
export function useHead (meta: MaybeComputedRef<MetaObject>): void
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Below are the non-reactive types for [`useHead`](/docs/3.x/api/composables/use-head) .
|
|
22
|
-
|
|
23
|
-
```ts
|
|
24
|
-
interface MetaObject {
|
|
25
|
-
title?: string
|
|
26
|
-
titleTemplate?: string | ((title?: string) => string)
|
|
27
|
-
base?: Base
|
|
28
|
-
link?: Link[]
|
|
29
|
-
meta?: Meta[]
|
|
30
|
-
style?: Style[]
|
|
31
|
-
script?: Script[]
|
|
32
|
-
noscript?: Noscript[]
|
|
33
|
-
htmlAttrs?: HtmlAttributes
|
|
34
|
-
bodyAttrs?: BodyAttributes
|
|
35
|
-
}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
See [@unhead/vue](https://github.com/unjs/unhead/blob/main/packages/vue/src/types/schema.ts) for more detailed types.
|
|
39
|
-
|
|
40
|
-
::note
|
|
41
|
-
The properties of `useHead` can be dynamic, accepting `ref`, `computed` and `reactive` properties. `meta` parameter can also accept a function returning an object to make the entire object reactive.
|
|
42
|
-
::
|
|
43
|
-
|
|
44
|
-
## Params
|
|
45
|
-
|
|
46
|
-
### `meta`
|
|
47
|
-
|
|
48
|
-
**Type**: `MetaObject`
|
|
49
|
-
|
|
50
|
-
An object accepting the following head metadata:
|
|
51
|
-
|
|
52
|
-
- `meta`: Each element in the array is mapped to a newly-created `<meta>` tag, where object properties are mapped to the corresponding attributes.
|
|
53
|
-
- **Type**: `Array<Record<string, any>>`
|
|
54
|
-
- `link`: Each element in the array is mapped to a newly-created `<link>` tag, where object properties are mapped to the corresponding attributes.
|
|
55
|
-
- **Type**: `Array<Record<string, any>>`
|
|
56
|
-
- `style`: Each element in the array is mapped to a newly-created `<style>` tag, where object properties are mapped to the corresponding attributes.
|
|
57
|
-
- **Type**: `Array<Record<string, any>>`
|
|
58
|
-
- `script`: Each element in the array is mapped to a newly-created `<script>` tag, where object properties are mapped to the corresponding attributes.
|
|
59
|
-
- **Type**: `Array<Record<string, any>>`
|
|
60
|
-
- `noscript`: Each element in the array is mapped to a newly-created `<noscript>` tag, where object properties are mapped to the corresponding attributes.
|
|
61
|
-
- **Type**: `Array<Record<string, any>>`
|
|
62
|
-
- `titleTemplate`: Configures dynamic template to customize the page title on an individual page.
|
|
63
|
-
- **Type**: `string` | `((title: string) => string)`
|
|
64
|
-
- `title`: Sets static page title on an individual page.
|
|
65
|
-
- **Type**: `string`
|
|
66
|
-
- `bodyAttrs`: Sets attributes of the `<body>` tag. Each object property is mapped to the corresponding attribute.
|
|
67
|
-
- **Type**: `Record<string, any>`
|
|
68
|
-
- `htmlAttrs`: Sets attributes of the `<html>` tag. Each object property is mapped to the corresponding attribute.
|
|
69
|
-
- **Type**: `Record<string, any>`
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: useLazyAsyncData
|
|
3
|
-
description: This wrapper around useAsyncData triggers navigation immediately.
|
|
4
|
-
links:
|
|
5
|
-
- label: Source
|
|
6
|
-
icon: i-simple-icons-github
|
|
7
|
-
to: https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/composables/asyncData.ts
|
|
8
|
-
size: xs
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Description
|
|
12
|
-
|
|
13
|
-
By default, [`useAsyncData`](/docs/3.x/api/composables/use-async-data) blocks navigation until its async handler is resolved. `useLazyAsyncData` provides a wrapper around [`useAsyncData`](/docs/3.x/api/composables/use-async-data) that triggers navigation before the handler is resolved by setting the `lazy` option to `true`.
|
|
14
|
-
|
|
15
|
-
::note
|
|
16
|
-
`useLazyAsyncData` has the same signature as [`useAsyncData`](/docs/3.x/api/composables/use-async-data).
|
|
17
|
-
::
|
|
18
|
-
|
|
19
|
-
:read-more{to="/docs/api/composables/use-async-data"}
|
|
20
|
-
|
|
21
|
-
## Example
|
|
22
|
-
|
|
23
|
-
```vue [pages/index.vue]
|
|
24
|
-
<script setup lang="ts">
|
|
25
|
-
/* Navigation will occur before fetching is complete.
|
|
26
|
-
Handle 'pending' and 'error' states directly within your component's template
|
|
27
|
-
*/
|
|
28
|
-
const { status, data: count } = await useLazyAsyncData('count', () => $fetch('/api/count'))
|
|
29
|
-
|
|
30
|
-
watch(count, (newCount) => {
|
|
31
|
-
// Because count might start out null, you won't have access
|
|
32
|
-
// to its contents immediately, but you can watch it.
|
|
33
|
-
})
|
|
34
|
-
</script>
|
|
35
|
-
|
|
36
|
-
<template>
|
|
37
|
-
<div>
|
|
38
|
-
{{ status === 'pending' ? 'Loading' : count }}
|
|
39
|
-
</div>
|
|
40
|
-
</template>
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
::warning
|
|
44
|
-
`useLazyAsyncData` is a reserved function name transformed by the compiler, so you should not name your own function `useLazyAsyncData`.
|
|
45
|
-
::
|
|
46
|
-
|
|
47
|
-
:read-more{to="/docs/getting-started/data-fetching"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: 'useLazyFetch'
|
|
3
|
-
description: This wrapper around useFetch triggers navigation immediately.
|
|
4
|
-
links:
|
|
5
|
-
- label: Source
|
|
6
|
-
icon: i-simple-icons-github
|
|
7
|
-
to: https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/composables/fetch.ts
|
|
8
|
-
size: xs
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Description
|
|
12
|
-
|
|
13
|
-
By default, [`useFetch`](/docs/3.x/api/composables/use-fetch) blocks navigation until its async handler is resolved. `useLazyFetch` provides a wrapper around [`useFetch`](/docs/3.x/api/composables/use-fetch) that triggers navigation before the handler is resolved by setting the `lazy` option to `true`.
|
|
14
|
-
|
|
15
|
-
::note
|
|
16
|
-
`useLazyFetch` has the same signature as [`useFetch`](/docs/3.x/api/composables/use-fetch).
|
|
17
|
-
::
|
|
18
|
-
|
|
19
|
-
::note
|
|
20
|
-
Awaiting `useLazyFetch` in this mode only ensures the call is initialized. On client-side navigation, data may not be immediately available, and you should make sure to handle the pending state in your app.
|
|
21
|
-
::
|
|
22
|
-
|
|
23
|
-
:read-more{to="/docs/api/composables/use-fetch"}
|
|
24
|
-
|
|
25
|
-
## Example
|
|
26
|
-
|
|
27
|
-
```vue [pages/index.vue]
|
|
28
|
-
<script setup lang="ts">
|
|
29
|
-
/* Navigation will occur before fetching is complete.
|
|
30
|
-
* Handle 'pending' and 'error' states directly within your component's template
|
|
31
|
-
*/
|
|
32
|
-
const { status, data: posts } = await useLazyFetch('/api/posts')
|
|
33
|
-
watch(posts, (newPosts) => {
|
|
34
|
-
// Because posts might start out null, you won't have access
|
|
35
|
-
// to its contents immediately, but you can watch it.
|
|
36
|
-
})
|
|
37
|
-
</script>
|
|
38
|
-
|
|
39
|
-
<template>
|
|
40
|
-
<div v-if="status === 'pending'">
|
|
41
|
-
Loading ...
|
|
42
|
-
</div>
|
|
43
|
-
<div v-else>
|
|
44
|
-
<div v-for="post in posts">
|
|
45
|
-
<!-- do something -->
|
|
46
|
-
</div>
|
|
47
|
-
</div>
|
|
48
|
-
</template>
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
::note
|
|
52
|
-
`useLazyFetch` is a reserved function name transformed by the compiler, so you should not name your own function `useLazyFetch`.
|
|
53
|
-
::
|
|
54
|
-
|
|
55
|
-
:read-more{to="/docs/getting-started/data-fetching"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|