@nuxt/docs 3.20.2 → 3.21.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/01.introduction.md +4 -4
- package/1.getting-started/02.installation.md +4 -7
- package/1.getting-started/03.configuration.md +29 -29
- package/1.getting-started/04.views.md +6 -4
- package/1.getting-started/05.assets.md +2 -2
- package/1.getting-started/06.styling.md +22 -16
- package/1.getting-started/07.routing.md +6 -6
- package/1.getting-started/08.seo-meta.md +8 -4
- package/1.getting-started/09.transitions.md +6 -6
- package/1.getting-started/10.data-fetching.md +18 -18
- package/1.getting-started/11.state-management.md +5 -5
- package/1.getting-started/12.error-handling.md +25 -19
- package/1.getting-started/13.server.md +9 -9
- package/1.getting-started/14.layers.md +49 -15
- package/1.getting-started/15.prerendering.md +18 -4
- package/1.getting-started/16.deployment.md +2 -1
- package/1.getting-started/17.testing.md +17 -7
- package/1.getting-started/18.upgrade.md +111 -60
- package/2.directory-structure/0.output.md +1 -1
- package/2.directory-structure/1.assets.md +1 -1
- package/2.directory-structure/1.components.md +12 -8
- package/2.directory-structure/1.composables.md +2 -2
- package/2.directory-structure/1.content.md +1 -1
- package/2.directory-structure/1.layers.md +87 -0
- package/2.directory-structure/1.layouts.md +35 -3
- package/2.directory-structure/1.middleware.md +7 -7
- package/2.directory-structure/1.modules.md +8 -2
- package/2.directory-structure/1.node_modules.md +1 -1
- package/2.directory-structure/1.pages.md +39 -18
- package/2.directory-structure/1.plugins.md +4 -1
- package/2.directory-structure/1.public.md +1 -1
- package/2.directory-structure/1.server.md +28 -8
- package/2.directory-structure/1.shared.md +3 -3
- package/2.directory-structure/1.utils.md +2 -2
- package/2.directory-structure/2.env.md +3 -3
- package/2.directory-structure/2.nuxtignore.md +1 -0
- package/2.directory-structure/2.nuxtrc.md +5 -2
- package/2.directory-structure/3.app-config.md +2 -2
- package/2.directory-structure/3.app.md +3 -3
- package/2.directory-structure/3.error.md +9 -5
- package/2.directory-structure/3.nuxt-config.md +1 -1
- package/2.directory-structure/3.package.md +1 -1
- package/2.directory-structure/3.tsconfig.md +3 -2
- package/2.directory-structure/index.md +12 -8
- package/3.guide/0.index.md +5 -2
- package/3.guide/1.concepts/{3.rendering.md → 1.rendering.md} +11 -32
- package/3.guide/1.concepts/{2.vuejs-development.md → 10.vuejs-development.md} +9 -8
- package/3.guide/1.concepts/{10.nuxt-lifecycle.md → 2.nuxt-lifecycle.md} +31 -24
- package/3.guide/1.concepts/{1.auto-imports.md → 3.auto-imports.md} +6 -6
- package/3.guide/1.concepts/4.server-engine.md +2 -2
- package/3.guide/1.concepts/5.modules.md +14 -1
- package/3.guide/1.concepts/7.esm.md +5 -4
- package/3.guide/1.concepts/8.typescript.md +9 -15
- package/3.guide/1.concepts/9.code-style.md +1 -1
- package/3.guide/2.best-practices/hydration.md +1 -1
- package/3.guide/2.best-practices/performance.md +5 -5
- package/3.guide/3.ai/.navigation.yml +3 -0
- package/3.guide/3.ai/1.mcp.md +277 -0
- package/3.guide/3.ai/2.llms-txt.md +65 -0
- package/3.guide/4.modules/.navigation.yml +3 -0
- package/3.guide/4.modules/1.getting-started.md +103 -0
- package/3.guide/4.modules/2.module-anatomy.md +138 -0
- package/3.guide/4.modules/3.recipes-basics.md +420 -0
- package/3.guide/4.modules/4.recipes-advanced.md +243 -0
- package/3.guide/4.modules/5.testing.md +76 -0
- package/3.guide/4.modules/6.best-practices.md +104 -0
- package/3.guide/4.modules/7.ecosystem.md +32 -0
- package/3.guide/4.modules/index.md +36 -0
- package/3.guide/{3.recipes → 5.recipes}/1.custom-routing.md +3 -3
- package/3.guide/{3.recipes → 5.recipes}/2.vite-plugin.md +4 -0
- package/3.guide/{3.recipes → 5.recipes}/3.custom-usefetch.md +2 -2
- package/3.guide/{3.recipes → 5.recipes}/4.sessions-and-authentication.md +3 -3
- package/3.guide/{4.going-further → 6.going-further}/1.events.md +3 -4
- package/3.guide/{4.going-further → 6.going-further}/1.experimental-features.md +211 -86
- package/3.guide/6.going-further/1.features.md +108 -0
- package/3.guide/{4.going-further → 6.going-further}/1.internals.md +4 -3
- package/3.guide/{4.going-further → 6.going-further}/10.runtime-config.md +2 -2
- package/3.guide/{4.going-further → 6.going-further}/11.nightly-release-channel.md +1 -1
- package/3.guide/{4.going-further → 6.going-further}/2.hooks.md +5 -5
- package/3.guide/{4.going-further → 6.going-further}/4.kit.md +3 -3
- package/3.guide/{4.going-further → 6.going-further}/6.nuxt-app.md +6 -6
- package/3.guide/{4.going-further → 6.going-further}/7.layers.md +31 -5
- package/3.guide/{4.going-further → 6.going-further}/9.debugging.md +3 -2
- package/4.api/1.components/1.nuxt-client-fallback.md +5 -1
- package/4.api/1.components/10.nuxt-picture.md +1 -1
- package/4.api/1.components/11.teleports.md +2 -2
- package/4.api/1.components/12.nuxt-route-announcer.md +0 -2
- package/4.api/1.components/13.nuxt-time.md +0 -2
- package/4.api/1.components/2.nuxt-page.md +3 -3
- package/4.api/1.components/3.nuxt-layout.md +6 -6
- package/4.api/1.components/4.nuxt-link.md +13 -13
- package/4.api/1.components/5.nuxt-loading-indicator.md +1 -1
- package/4.api/1.components/6.nuxt-error-boundary.md +2 -2
- package/4.api/1.components/7.nuxt-welcome.md +2 -2
- package/4.api/1.components/8.nuxt-island.md +9 -2
- package/4.api/2.composables/use-app-config.md +1 -1
- package/4.api/2.composables/use-async-data.md +5 -5
- package/4.api/2.composables/use-cookie.md +16 -16
- package/4.api/2.composables/use-error.md +3 -3
- package/4.api/2.composables/use-fetch.md +37 -37
- package/4.api/2.composables/use-head-safe.md +1 -1
- package/4.api/2.composables/use-head.md +22 -7
- package/4.api/2.composables/use-lazy-async-data.md +1 -1
- package/4.api/2.composables/use-lazy-fetch.md +9 -9
- package/4.api/2.composables/use-nuxt-app.md +9 -7
- package/4.api/2.composables/use-route-announcer.md +1 -3
- package/4.api/2.composables/use-route.md +2 -2
- package/4.api/2.composables/use-router.md +15 -15
- package/4.api/2.composables/use-runtime-config.md +5 -5
- package/4.api/2.composables/use-seo-meta.md +2 -2
- package/4.api/2.composables/use-server-seo-meta.md +2 -2
- package/4.api/2.composables/use-state.md +12 -2
- package/4.api/3.utils/$fetch.md +1 -1
- package/4.api/3.utils/abort-navigation.md +2 -2
- package/4.api/3.utils/call-once.md +2 -4
- package/4.api/3.utils/clear-error.md +1 -1
- package/4.api/3.utils/create-error.md +7 -7
- package/4.api/3.utils/define-lazy-hydration-component.md +5 -5
- package/4.api/3.utils/define-nuxt-component.md +1 -1
- package/4.api/3.utils/define-nuxt-plugin.md +12 -12
- package/4.api/3.utils/define-nuxt-route-middleware.md +2 -2
- package/4.api/3.utils/define-page-meta.md +18 -11
- package/4.api/3.utils/define-route-rules.md +2 -2
- package/4.api/3.utils/navigate-to.md +14 -14
- package/4.api/3.utils/on-before-route-leave.md +1 -1
- package/4.api/3.utils/on-before-route-update.md +1 -1
- package/4.api/3.utils/preload-route-components.md +2 -2
- package/4.api/3.utils/refresh-cookie.md +0 -2
- package/4.api/3.utils/refresh-nuxt-data.md +1 -1
- package/4.api/3.utils/reload-nuxt-app.md +1 -1
- package/4.api/3.utils/set-page-layout.md +36 -0
- package/4.api/3.utils/set-response-status.md +3 -3
- package/4.api/3.utils/show-error.md +4 -4
- package/4.api/3.utils/update-app-config.md +1 -1
- package/4.api/4.commands/add.md +12 -12
- package/4.api/4.commands/analyze.md +11 -11
- package/4.api/4.commands/build-module.md +11 -11
- package/4.api/4.commands/build.md +12 -12
- package/4.api/4.commands/cleanup.md +6 -6
- package/4.api/4.commands/dev.md +23 -23
- package/4.api/4.commands/devtools.md +7 -7
- package/4.api/4.commands/generate.md +12 -12
- package/4.api/4.commands/info.md +6 -6
- package/4.api/4.commands/init.md +18 -18
- package/4.api/4.commands/module.md +18 -18
- package/4.api/4.commands/prepare.md +10 -10
- package/4.api/4.commands/preview.md +11 -11
- package/4.api/4.commands/test.md +9 -9
- package/4.api/4.commands/typecheck.md +10 -10
- package/4.api/4.commands/upgrade.md +10 -10
- package/4.api/5.kit/1.modules.md +31 -18
- package/4.api/5.kit/10.templates.md +23 -23
- package/4.api/5.kit/11.nitro.md +40 -36
- package/4.api/5.kit/12.resolving.md +2 -2
- package/4.api/5.kit/14.builder.md +35 -23
- package/4.api/5.kit/16.layers.md +16 -16
- package/4.api/5.kit/2.programmatic.md +2 -2
- package/4.api/5.kit/3.compatibility.md +2 -2
- package/4.api/5.kit/4.autoimports.md +23 -19
- package/4.api/5.kit/5.components.md +35 -35
- package/4.api/5.kit/6.context.md +1 -1
- package/4.api/5.kit/8.layout.md +1 -1
- package/4.api/6.advanced/1.hooks.md +85 -85
- package/4.api/index.md +7 -7
- package/5.community/4.contribution.md +10 -10
- package/5.community/5.framework-contribution.md +9 -9
- package/5.community/6.roadmap.md +26 -26
- package/5.community/7.changelog.md +10 -0
- package/6.bridge/1.overview.md +8 -0
- package/6.bridge/3.bridge-composition-api.md +2 -2
- package/6.bridge/4.plugins-and-middleware.md +2 -2
- package/6.bridge/5.nuxt3-compatible-api.md +1 -1
- package/6.bridge/8.nitro.md +4 -0
- package/7.migration/10.bundling.md +1 -1
- package/7.migration/11.server.md +3 -3
- package/7.migration/2.configuration.md +5 -5
- package/7.migration/20.module-authors.md +3 -3
- package/7.migration/4.meta.md +1 -1
- package/7.migration/5.plugins-and-middleware.md +3 -3
- package/7.migration/6.pages-and-layouts.md +5 -5
- package/7.migration/7.component-options.md +6 -6
- package/7.migration/8.runtime-config.md +1 -1
- package/package.json +1 -1
- package/3.guide/4.going-further/1.features.md +0 -103
- package/3.guide/4.going-further/3.modules.md +0 -901
- /package/3.guide/{3.recipes → 5.recipes}/.navigation.yml +0 -0
- /package/3.guide/{4.going-further → 6.going-further}/.navigation.yml +0 -0
- /package/3.guide/{4.going-further → 6.going-further}/index.md +0 -0
package/3.guide/0.index.md
CHANGED
|
@@ -11,12 +11,15 @@ surround: false
|
|
|
11
11
|
Discover the main concepts behind Nuxt, from auto-import, hybrid rendering to its TypeScript support.
|
|
12
12
|
::
|
|
13
13
|
::card{icon="i-lucide-square-check" title="Best Practices" to="/docs/3.x/guide/best-practices"}
|
|
14
|
-
Learn about best practices when developing with Nuxt
|
|
14
|
+
Learn about best practices when developing with Nuxt.
|
|
15
|
+
::
|
|
16
|
+
::card{icon="i-lucide-box" title="Module Author Guide" to="/docs/3.x/guide/modules"}
|
|
17
|
+
Learn how to create Nuxt modules to integrate, enhance or extend any Nuxt application.
|
|
15
18
|
::
|
|
16
19
|
::card{icon="i-lucide-book-open" title="Recipes" to="/docs/3.x/guide/recipes"}
|
|
17
20
|
Find solutions to common problems and learn how to implement them in your Nuxt project.
|
|
18
21
|
::
|
|
19
22
|
::card{icon="i-lucide-star" title="Going Further" to="/docs/3.x/guide/going-further"}
|
|
20
|
-
Master Nuxt with advanced concepts like experimental features, hooks,
|
|
23
|
+
Master Nuxt with advanced concepts like experimental features, hooks, and more.
|
|
21
24
|
::
|
|
22
25
|
::
|
|
@@ -3,7 +3,7 @@ title: 'Rendering Modes'
|
|
|
3
3
|
description: 'Learn about the different rendering modes available in Nuxt.'
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
Nuxt supports different rendering modes, [universal rendering](#universal-rendering), [client-side rendering](#client-side-rendering) but also offers [hybrid-rendering](#hybrid-rendering) and the possibility to render your application on [CDN Edge Servers](#edge-side-rendering).
|
|
6
|
+
Nuxt supports different rendering modes, [universal rendering](/docs/3.x/guide/concepts/rendering#universal-rendering), [client-side rendering](/docs/3.x/guide/concepts/rendering#client-side-rendering) but also offers [hybrid-rendering](/docs/3.x/guide/concepts/rendering#hybrid-rendering) and the possibility to render your application on [CDN Edge Servers](/docs/3.x/guide/concepts/rendering#edge-side-rendering).
|
|
7
7
|
|
|
8
8
|
Both the browser and server can interpret JavaScript code to turn Vue.js components into HTML elements. This step is called **rendering**. Nuxt supports both **universal** and **client-side** rendering. The two approaches have benefits and downsides that we will cover.
|
|
9
9
|
|
|
@@ -52,12 +52,12 @@ On the initial request, the `counter` ref is initialized in the server since it
|
|
|
52
52
|
|
|
53
53
|
**Downsides of server-side rendering:**
|
|
54
54
|
- **Development constraints:** Server and browser environments don't provide the same APIs, and it can be tricky to write code that can run on both sides seamlessly. Fortunately, Nuxt provides guidelines and specific variables to help you determine where a piece of code is executed.
|
|
55
|
-
- **Cost:** A server needs to be running in order to render pages on the fly. This adds a monthly cost like any traditional server. However, the server calls are highly reduced thanks to universal rendering with the browser taking over on client-side navigation. A cost reduction is possible by leveraging [edge-side-rendering](#edge-side-rendering).
|
|
55
|
+
- **Cost:** A server needs to be running in order to render pages on the fly. This adds a monthly cost like any traditional server. However, the server calls are highly reduced thanks to universal rendering with the browser taking over on client-side navigation. A cost reduction is possible by leveraging [edge-side-rendering](/docs/3.x/guide/concepts/rendering#edge-side-rendering).
|
|
56
56
|
|
|
57
57
|
Universal rendering is very versatile and can fit almost any use case, and is especially appropriate for any content-oriented websites: **blogs, marketing websites, portfolios, e-commerce sites, and marketplaces.**
|
|
58
58
|
|
|
59
59
|
::tip
|
|
60
|
-
For more examples about writing Vue code without hydration mismatch, see [the Vue docs](https://vuejs.org/guide/scaling-up/ssr
|
|
60
|
+
For more examples about writing Vue code without hydration mismatch, see [the Vue docs](https://vuejs.org/guide/scaling-up/ssr#hydration-mismatch).
|
|
61
61
|
::
|
|
62
62
|
|
|
63
63
|
::important
|
|
@@ -91,7 +91,7 @@ export default defineNuxtConfig({
|
|
|
91
91
|
|
|
92
92
|
::note
|
|
93
93
|
If you do use `ssr: false`, you should also place an HTML file in `~/app/spa-loading-template.html` with some HTML you would like to use to render a loading screen that will be rendered until your app is hydrated.
|
|
94
|
-
:read-more{title="SPA Loading Template" to="/docs/api/configuration/nuxt-config#spaloadingtemplate"}
|
|
94
|
+
:read-more{title="SPA Loading Template" to="/docs/3.x/api/configuration/nuxt-config#spaloadingtemplate"}
|
|
95
95
|
::
|
|
96
96
|
|
|
97
97
|
:video-accordion{title="Watch a video from Alexander Lichter about Building a plain SPA with Nuxt" videoId="7Lr0QTP1Ro8"}
|
|
@@ -131,6 +131,7 @@ The `200.html` and `404.html` might be useful for the hosting provider you are u
|
|
|
131
131
|
When prerendering a client-rendered app, Nuxt will generate `index.html`, `200.html` and `404.html` files by default. However, if you need to prevent any (or all) of these files from being generated in your build, you can use the `'prerender:generate'` hook from [Nitro](/docs/3.x/getting-started/prerendering#prerendergenerate-nitro-hook).
|
|
132
132
|
|
|
133
133
|
```ts twoslash [nuxt.config.ts]
|
|
134
|
+
// @errors: 2353 7006
|
|
134
135
|
export default defineNuxtConfig({
|
|
135
136
|
ssr: false,
|
|
136
137
|
nitro: {
|
|
@@ -192,6 +193,10 @@ The different properties you can use are the following:
|
|
|
192
193
|
- `noScripts: boolean`{lang=ts} - Disables rendering of Nuxt scripts and JS resource hints for sections of your site.
|
|
193
194
|
- `appMiddleware: string | string[] | Record<string, boolean>`{lang=ts} - Allows you to define middleware that should or should not run for page paths within the Vue app part of your application (that is, not your Nitro routes)
|
|
194
195
|
|
|
196
|
+
::note
|
|
197
|
+
Routes using `isr` or `swr` also generate `_payload.json` files alongside HTML. Client-side navigation loads these cached payloads instead of re-fetching data. Configure dynamic routes like `pages/[...slug].vue` with glob patterns: `'/**': { isr: true }`.
|
|
198
|
+
::
|
|
199
|
+
|
|
195
200
|
Whenever possible, route rules will be automatically applied to the deployment platform's native rules for optimal performances (Netlify and Vercel are currently supported).
|
|
196
201
|
|
|
197
202
|
::important
|
|
@@ -225,33 +230,7 @@ Edge-side rendering is possible thanks to [Nitro](https://nitro.build/), the [se
|
|
|
225
230
|
|
|
226
231
|
The current platforms where you can leverage ESR are:
|
|
227
232
|
- [Cloudflare Pages](https://pages.cloudflare.com) with zero configuration using the git integration and the `nuxt build` command
|
|
228
|
-
- [Vercel
|
|
229
|
-
- [Netlify Edge Functions](https://www.netlify.com/
|
|
233
|
+
- [Vercel Cloud](https://vercel.com/home) using the `nuxt build` command and `NITRO_PRESET=vercel-edge` environment variable
|
|
234
|
+
- [Netlify Edge Functions](https://www.netlify.com/platform/#netlify-edge-functions) using the `nuxt build` command and `NITRO_PRESET=netlify-edge` environment variable
|
|
230
235
|
|
|
231
236
|
Note that **Hybrid Rendering** can be used when using Edge-Side Rendering with route rules.
|
|
232
|
-
|
|
233
|
-
You can explore open source examples deployed on some of the platform mentioned above:
|
|
234
|
-
::card-group
|
|
235
|
-
::card
|
|
236
|
-
---
|
|
237
|
-
icon: i-simple-icons-github
|
|
238
|
-
title: Nuxt Todos Edge
|
|
239
|
-
to: https://github.com/atinux/nuxt-todos-edge
|
|
240
|
-
target: _blank
|
|
241
|
-
ui.icon.base: text-black dark:text-white
|
|
242
|
-
---
|
|
243
|
-
A todos application with user authentication, SSR and SQLite.
|
|
244
|
-
::
|
|
245
|
-
::card
|
|
246
|
-
---
|
|
247
|
-
icon: i-simple-icons-github
|
|
248
|
-
title: Atinotes
|
|
249
|
-
to: https://github.com/atinux/atinotes
|
|
250
|
-
target: _blank
|
|
251
|
-
ui.icon.base: text-black dark:text-white
|
|
252
|
-
---
|
|
253
|
-
An editable website with universal rendering based on Cloudflare KV.
|
|
254
|
-
::
|
|
255
|
-
::
|
|
256
|
-
|
|
257
|
-
<!-- TODO: link to templates with ESR category for examples -->
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: 'Vue.js Development'
|
|
3
3
|
description: "Nuxt uses Vue.js and adds features such as component auto-imports, file-based routing and composables for an SSR-friendly usage."
|
|
4
|
+
navigation: false
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
Nuxt integrates Vue 3, the new major release of Vue that enables new patterns for Nuxt users.
|
|
@@ -21,21 +22,21 @@ We chose to build Nuxt on top of Vue for these reasons:
|
|
|
21
22
|
|
|
22
23
|
### Single File Components
|
|
23
24
|
|
|
24
|
-
[Vue’s single-file components](https://vuejs.org/guide/scaling-up/sfc
|
|
25
|
+
[Vue’s single-file components](https://vuejs.org/guide/scaling-up/sfc) (SFC or `*.vue` files) encapsulate the markup (`<template>`), logic (`<script>`) and styling (`<style>`) of a Vue component. Nuxt provides a zero-config experience for SFCs with [Hot Module Replacement](https://vite.dev/guide/features#hot-module-replacement) that offers a seamless developer experience.
|
|
25
26
|
|
|
26
27
|
### Auto-imports
|
|
27
28
|
|
|
28
29
|
Every Vue component created in the [`components/`](/docs/3.x/directory-structure/components) directory of a Nuxt project will be available in your project without having to import it. If a component is not used anywhere, your production’s code will not include it.
|
|
29
30
|
|
|
30
|
-
:read-more{to="/docs/guide/concepts/auto-imports"}
|
|
31
|
+
:read-more{to="/docs/3.x/guide/concepts/auto-imports"}
|
|
31
32
|
|
|
32
33
|
### Vue Router
|
|
33
34
|
|
|
34
|
-
Most applications need multiple pages and a way to navigate between them. This is called **routing**. Nuxt uses
|
|
35
|
+
Most applications need multiple pages and a way to navigate between them. This is called **routing**. Nuxt uses an [`pages/`](/docs/3.x/directory-structure/pages) directory and naming conventions to directly create routes mapped to your files using the official [Vue Router library](https://router.vuejs.org).
|
|
35
36
|
|
|
36
|
-
:read-more{to="/docs/getting-started/routing"}
|
|
37
|
+
:read-more{to="/docs/3.x/getting-started/routing"}
|
|
37
38
|
|
|
38
|
-
:link-example{to="/docs/examples/features/auto-imports"}
|
|
39
|
+
:link-example{to="/docs/3.x/examples/features/auto-imports"}
|
|
39
40
|
|
|
40
41
|
## Differences with Nuxt 2 / Vue 2
|
|
41
42
|
|
|
@@ -78,7 +79,7 @@ export default {
|
|
|
78
79
|
</script>
|
|
79
80
|
```
|
|
80
81
|
|
|
81
|
-
The [Composition API](https://vuejs.org/guide/extras/composition-api-faq
|
|
82
|
+
The [Composition API](https://vuejs.org/guide/extras/composition-api-faq) introduced in Vue 3 is not a replacement of the Options API, but it enables better logic reuse throughout an application, and is a more natural way to group code by concern in complex components.
|
|
82
83
|
|
|
83
84
|
Used with the `setup` keyword in the `<script>` definition, here is the above component rewritten with Composition API and Nuxt 3’s auto-imported Reactivity APIs:
|
|
84
85
|
|
|
@@ -91,13 +92,13 @@ const increment = () => count.value++
|
|
|
91
92
|
|
|
92
93
|
The goal of Nuxt is to provide a great developer experience around the Composition API.
|
|
93
94
|
|
|
94
|
-
- Use auto-imported [Reactivity functions](https://vuejs.org/api/reactivity-core
|
|
95
|
+
- Use auto-imported [Reactivity functions](https://vuejs.org/api/reactivity-core) from Vue and Nuxt [built-in composables](/docs/3.x/api/composables/use-async-data).
|
|
95
96
|
- Write your own auto-imported reusable functions in the [`composables/` directory](/docs/3.x/directory-structure/composables).
|
|
96
97
|
|
|
97
98
|
### TypeScript Support
|
|
98
99
|
|
|
99
100
|
Both Vue 3 and Nuxt 3+ are written in TypeScript. A fully typed codebase prevents mistakes and documents APIs usage. This doesn’t mean that you have to write your application in TypeScript to take advantage of it. With Nuxt 3, you can opt-in by renaming your file from `.js` to `.ts` , or add `<script setup lang="ts">` in a component.
|
|
100
101
|
|
|
101
|
-
::read-more{to="/docs/guide/concepts/typescript"}
|
|
102
|
+
::read-more{to="/docs/3.x/guide/concepts/typescript"}
|
|
102
103
|
Read the details about TypeScript in Nuxt
|
|
103
104
|
::
|
|
@@ -5,15 +5,16 @@ description: "Understanding the lifecycle of Nuxt applications can help you gain
|
|
|
5
5
|
|
|
6
6
|
The goal of this chapter is to provide a high-level overview of the different parts of the framework, their execution order, and how they work together.
|
|
7
7
|
|
|
8
|
-
## Server
|
|
8
|
+
## Server lifecycle
|
|
9
9
|
|
|
10
10
|
On the server, the following steps are executed for every initial request to your application:
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
::steps
|
|
13
|
+
### Server plugins :badge[once]{color="info" class="align-middle"}
|
|
13
14
|
|
|
14
15
|
Nuxt is powered by [Nitro](https://nitro.build/), a modern server engine.
|
|
15
16
|
|
|
16
|
-
When Nitro starts, it initializes and executes the plugins under the `/server/plugins` directory. These plugins can:
|
|
17
|
+
When Nitro starts, it initializes and executes the plugins under the [`/server/plugins`](/docs/3.x/directory-structure/server#server-plugins) directory. These plugins can:
|
|
17
18
|
- Capture and handle application-wide errors.
|
|
18
19
|
- Register hooks that execute when Nitro shuts down.
|
|
19
20
|
- Register hooks for request lifecycle events, such as modifying responses.
|
|
@@ -22,9 +23,9 @@ When Nitro starts, it initializes and executes the plugins under the `/server/pl
|
|
|
22
23
|
Nitro plugins are executed only once when the server starts. In a serverless environment, the server boots on each incoming request, and so do the Nitro plugins. However, they are not awaited.
|
|
23
24
|
::
|
|
24
25
|
|
|
25
|
-
:read-more{to="/docs/
|
|
26
|
+
:read-more{to="/docs/3.x/directory-structure/server#server-plugins"}
|
|
26
27
|
|
|
27
|
-
###
|
|
28
|
+
### Server middleware
|
|
28
29
|
|
|
29
30
|
After initializing the Nitro server, middleware under `server/middleware/` is executed for every request. Middleware can be used for tasks such as authentication, logging, or request transformation.
|
|
30
31
|
|
|
@@ -32,11 +33,11 @@ After initializing the Nitro server, middleware under `server/middleware/` is ex
|
|
|
32
33
|
Returning a value from middleware will terminate the request and send the returned value as the response. This behavior should generally be avoided to ensure proper request handling!
|
|
33
34
|
::
|
|
34
35
|
|
|
35
|
-
:read-more{to="/docs/
|
|
36
|
+
:read-more{to="/docs/3.x/directory-structure/server#server-middleware"}
|
|
36
37
|
|
|
37
|
-
###
|
|
38
|
+
### App plugins
|
|
38
39
|
|
|
39
|
-
The Vue and Nuxt instances are created first. Afterward, Nuxt executes its
|
|
40
|
+
The Vue and Nuxt instances are created first. Afterward, Nuxt executes its app plugins. This includes:
|
|
40
41
|
- Built-in plugins, such as Vue Router and `unhead`.
|
|
41
42
|
- Custom plugins located in the `plugins/` directory, including those without a suffix (e.g., `myPlugin.ts`) and those with the `.server` suffix (e.g., `myServerPlugin.server.ts`).
|
|
42
43
|
|
|
@@ -46,20 +47,20 @@ Plugins execute in a specific order and may have dependencies on one another. Fo
|
|
|
46
47
|
After this step, Nuxt calls the [`app:created`](/docs/3.x/api/advanced/hooks#app-hooks-runtime) hook, which can be used to execute additional logic.
|
|
47
48
|
::
|
|
48
49
|
|
|
49
|
-
:read-more{to="/docs/
|
|
50
|
+
:read-more{to="/docs/3.x/directory-structure/plugins"}
|
|
50
51
|
|
|
51
|
-
###
|
|
52
|
+
### Route validation
|
|
52
53
|
|
|
53
54
|
After initializing plugins and before executing middleware, Nuxt calls the `validate` method if it is defined in the `definePageMeta` function. The `validate` method, which can be synchronous or asynchronous, is often used to validate dynamic route parameters.
|
|
54
55
|
|
|
55
56
|
- The `validate` function should return `true` if the parameters are valid.
|
|
56
|
-
- If validation fails, it should return `false` or an object containing a `
|
|
57
|
+
- If validation fails, it should return `false` or an object containing a `status` and/or `statusText` to terminate the request.
|
|
57
58
|
|
|
58
59
|
For more information, see the [Route Validation documentation](/docs/3.x/getting-started/routing#route-validation).
|
|
59
60
|
|
|
60
|
-
:read-more{to="/docs/getting-started/routing#route-validation"}
|
|
61
|
+
:read-more{to="/docs/3.x/getting-started/routing#route-validation"}
|
|
61
62
|
|
|
62
|
-
###
|
|
63
|
+
### App middleware
|
|
63
64
|
|
|
64
65
|
Middleware allows you to run code before navigating to a particular route. It is often used for tasks such as authentication, redirection, or logging.
|
|
65
66
|
|
|
@@ -74,9 +75,9 @@ For details about each type and examples, see the [Middleware documentation](/do
|
|
|
74
75
|
|
|
75
76
|
Any redirection on the server will result in a `Location:` header being sent to the browser; the browser then makes a fresh request to this new location. All application state will be reset when this happens, unless persisted in a cookie.
|
|
76
77
|
|
|
77
|
-
:read-more{to="/docs/
|
|
78
|
+
:read-more{to="/docs/3.x/directory-structure/middleware"}
|
|
78
79
|
|
|
79
|
-
###
|
|
80
|
+
### Page and components
|
|
80
81
|
|
|
81
82
|
Nuxt renders the page and its components and fetches any required data with `useFetch` and `useAsyncData` during this step. Since there are no dynamic updates and no DOM operations occur on the server, Vue lifecycle hooks such as `onBeforeMount`, `onMounted`, and subsequent hooks are **NOT** executed during SSR.
|
|
82
83
|
|
|
@@ -94,7 +95,7 @@ You should avoid code that produces side effects that need cleanup in root scope
|
|
|
94
95
|
Watch a video from Daniel Roe explaining Server Rendering and Global State.
|
|
95
96
|
::
|
|
96
97
|
|
|
97
|
-
###
|
|
98
|
+
### HTML Output
|
|
98
99
|
|
|
99
100
|
After all required data is fetched and the components are rendered, Nuxt combines the rendered components with settings from `unhead` to generate a complete HTML document. This HTML, along with the associated data, is then sent back to the client to complete the SSR process.
|
|
100
101
|
|
|
@@ -106,11 +107,15 @@ After rendering the Vue application to HTML, Nuxt calls the [`app:rendered`](/do
|
|
|
106
107
|
Before finalizing and sending the HTML, Nitro will call the [`render:html`](/docs/3.x/api/advanced/hooks#nitro-app-hooks-runtime-server-side) hook. This hook allows you to manipulate the generated HTML, such as injecting additional scripts or modifying meta tags.
|
|
107
108
|
::
|
|
108
109
|
|
|
109
|
-
|
|
110
|
+
::
|
|
111
|
+
|
|
112
|
+
## Client lifecycle
|
|
110
113
|
|
|
111
114
|
This part of the lifecycle is fully executed in the browser, no matter which Nuxt mode you've chosen.
|
|
112
115
|
|
|
113
|
-
|
|
116
|
+
::steps
|
|
117
|
+
|
|
118
|
+
### App plugins
|
|
114
119
|
|
|
115
120
|
This step is similar to the server-side execution and includes both built-in and custom plugins.
|
|
116
121
|
|
|
@@ -120,19 +125,19 @@ Custom plugins in the `plugins/` directory, such as those without a suffix (e.g.
|
|
|
120
125
|
After this step, Nuxt calls the [`app:created`](/docs/3.x/api/advanced/hooks#app-hooks-runtime) hook, which can be used to execute additional logic.
|
|
121
126
|
::
|
|
122
127
|
|
|
123
|
-
:read-more{to="/docs/
|
|
128
|
+
:read-more{to="/docs/3.x/directory-structure/plugins"}
|
|
124
129
|
|
|
125
|
-
###
|
|
130
|
+
### Route validation
|
|
126
131
|
|
|
127
132
|
This step is the same as the server-side execution and includes the `validate` method if defined in the `definePageMeta` function.
|
|
128
133
|
|
|
129
|
-
###
|
|
134
|
+
### App middleware
|
|
130
135
|
|
|
131
136
|
Nuxt middleware runs on both the server and the client. If you want certain code to run in specific environments, consider splitting it by using `import.meta.client` for the client and `import.meta.server` for the server.
|
|
132
137
|
|
|
133
|
-
:read-more{to="/docs/
|
|
138
|
+
:read-more{to="/docs/3.x/directory-structure/middleware#when-middleware-runs"}
|
|
134
139
|
|
|
135
|
-
###
|
|
140
|
+
### Mount Vue app and hydrate
|
|
136
141
|
|
|
137
142
|
Calling `app.mount('#__nuxt')` mounts the Vue application to the DOM. If the application uses SSR or SSG mode, Vue performs a hydration step to make the client-side application interactive. During hydration, Vue recreates the application (excluding [Server Components](/docs/3.x/directory-structure/components#server-components)), matches each component to its corresponding DOM nodes, and attaches DOM event listeners.
|
|
138
143
|
|
|
@@ -146,6 +151,8 @@ Before mounting the Vue application, Nuxt calls the [`app:beforeMount`](/docs/3.
|
|
|
146
151
|
After mounting the Vue application, Nuxt calls the [`app:mounted`](/docs/3.x/api/advanced/hooks#app-hooks-runtime) hook.
|
|
147
152
|
::
|
|
148
153
|
|
|
149
|
-
###
|
|
154
|
+
### Vue lifecycle
|
|
150
155
|
|
|
151
156
|
Unlike on the server, the browser executes the full [Vue lifecycle](https://vuejs.org/guide/essentials/lifecycle).
|
|
157
|
+
|
|
158
|
+
::
|
|
@@ -3,7 +3,7 @@ title: Auto-imports
|
|
|
3
3
|
description: "Nuxt auto-imports components, composables, helper functions and Vue APIs."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
Nuxt auto-imports components, composables and [Vue.js APIs](https://vuejs.org/api) to use across your application without explicitly importing them.
|
|
6
|
+
Nuxt auto-imports components, composables and [Vue.js APIs](https://vuejs.org/api/) to use across your application without explicitly importing them.
|
|
7
7
|
|
|
8
8
|
```vue twoslash [app.vue]
|
|
9
9
|
<script setup lang="ts">
|
|
@@ -66,7 +66,7 @@ If you get an error message like `Nuxt instance is unavailable` then it probably
|
|
|
66
66
|
When using a composable that requires the Nuxt context inside a non-SFC component, you need to wrap your component with `defineNuxtComponent` instead of `defineComponent`
|
|
67
67
|
::
|
|
68
68
|
|
|
69
|
-
::read-more{to="/docs/guide/going-further/experimental-features#asynccontext" icon="i-lucide-star"}
|
|
69
|
+
::read-more{to="/docs/3.x/guide/going-further/experimental-features#asynccontext" icon="i-lucide-star"}
|
|
70
70
|
Checkout the `asyncContext` experimental feature to use Nuxt composables in async functions.
|
|
71
71
|
::
|
|
72
72
|
|
|
@@ -105,11 +105,11 @@ Nuxt directly auto-imports files created in defined directories:
|
|
|
105
105
|
- `composables/` for [Vue composables](/docs/3.x/directory-structure/composables).
|
|
106
106
|
- `utils/` for helper functions and other utilities.
|
|
107
107
|
|
|
108
|
-
:link-example{to="/docs/examples/features/auto-imports"}
|
|
108
|
+
:link-example{to="/docs/3.x/examples/features/auto-imports"}
|
|
109
109
|
|
|
110
110
|
::warning
|
|
111
111
|
**Auto-imported `ref` and `computed` won't be unwrapped in a component `<template>`.** :br
|
|
112
|
-
This is due to how Vue works with refs that aren't top-level to the template. You can read more about it [in the Vue documentation](https://vuejs.org/guide/essentials/reactivity-fundamentals
|
|
112
|
+
This is due to how Vue works with refs that aren't top-level to the template. You can read more about it [in the Vue documentation](https://vuejs.org/guide/essentials/reactivity-fundamentals#caveat-when-unwrapping-in-templates).
|
|
113
113
|
::
|
|
114
114
|
|
|
115
115
|
### Explicit Imports
|
|
@@ -139,7 +139,7 @@ export default defineNuxtConfig({
|
|
|
139
139
|
})
|
|
140
140
|
```
|
|
141
141
|
|
|
142
|
-
This will disable auto-imports completely but it's still possible to use [explicit imports](#explicit-imports) from `#imports`.
|
|
142
|
+
This will disable auto-imports completely but it's still possible to use [explicit imports](/docs/3.x/guide/concepts/auto-imports#explicit-imports) from `#imports`.
|
|
143
143
|
|
|
144
144
|
### Partially Disabling Auto-imports
|
|
145
145
|
|
|
@@ -167,7 +167,7 @@ With this configuration:
|
|
|
167
167
|
|
|
168
168
|
Nuxt also automatically imports components from your `~/components` directory, although this is configured separately from auto-importing composables and utility functions.
|
|
169
169
|
|
|
170
|
-
:read-more{to="/docs/
|
|
170
|
+
:read-more{to="/docs/3.x/directory-structure/components"}
|
|
171
171
|
|
|
172
172
|
To disable auto-importing components from your own `~/components` directory, you can set `components.dirs` to an empty array (though note that this will not affect components added by modules).
|
|
173
173
|
|
|
@@ -16,7 +16,7 @@ It is shipped with many features:
|
|
|
16
16
|
|
|
17
17
|
## API Layer
|
|
18
18
|
|
|
19
|
-
Server [API endpoints](/docs/3.x/directory-structure/server#
|
|
19
|
+
Server [API endpoints](/docs/3.x/directory-structure/server#server-routes) and [Middleware](/docs/3.x/directory-structure/server#server-middleware) are added by Nitro that internally uses [h3](https://github.com/h3js/h3).
|
|
20
20
|
|
|
21
21
|
Key features include:
|
|
22
22
|
|
|
@@ -26,7 +26,7 @@ Key features include:
|
|
|
26
26
|
|
|
27
27
|
Check out [the h3 docs](https://github.com/h3js/h3) for more information.
|
|
28
28
|
|
|
29
|
-
::read-more{to="/docs/
|
|
29
|
+
::read-more{to="/docs/3.x/directory-structure/server#server-routes"}
|
|
30
30
|
Learn more about the API layer in the `server/` directory.
|
|
31
31
|
::
|
|
32
32
|
|
|
@@ -41,8 +41,21 @@ export default defineNuxtConfig({
|
|
|
41
41
|
Nuxt modules are now build-time-only, and the `buildModules` property used in Nuxt 2 is deprecated in favor of `modules`.
|
|
42
42
|
::
|
|
43
43
|
|
|
44
|
+
## Disabling Modules
|
|
45
|
+
|
|
46
|
+
You can disable a module by setting its config key to `false` in your Nuxt config. This is particularly useful when you want to disable modules inherited from layers.
|
|
47
|
+
|
|
48
|
+
```ts [nuxt.config.ts]
|
|
49
|
+
export default defineNuxtConfig({
|
|
50
|
+
// Disable `@nuxt/image` module
|
|
51
|
+
image: false,
|
|
52
|
+
})
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
:read-more{to="/docs/3.x/guide/going-further/layers#disabling-modules-from-layers"}
|
|
56
|
+
|
|
44
57
|
## Create a Nuxt Module
|
|
45
58
|
|
|
46
59
|
Everyone has the opportunity to develop modules and we cannot wait to see what you will build.
|
|
47
60
|
|
|
48
|
-
:read-more{to="/docs/guide/
|
|
61
|
+
:read-more{to="/docs/3.x/guide/modules" title="Module Author Guide"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: 'ES Modules'
|
|
3
3
|
description: "Nuxt uses native ES modules."
|
|
4
|
+
navigation: false
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
This guide helps explain what ES Modules are and how to make a Nuxt app (or upstream library) compatible with ESM.
|
|
@@ -31,7 +32,7 @@ export { a }
|
|
|
31
32
|
```
|
|
32
33
|
|
|
33
34
|
Before ECMAScript Modules (ESM) became a standard (it took more than 10 years!), tooling like
|
|
34
|
-
[webpack](https://webpack.js.org/guides/ecma-script-modules) and even languages like TypeScript started supporting so-called **ESM syntax**.
|
|
35
|
+
[webpack](https://webpack.js.org/guides/ecma-script-modules/) and even languages like TypeScript started supporting so-called **ESM syntax**.
|
|
35
36
|
However, there are some key differences with actual spec; here's [a helpful explainer](https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/).
|
|
36
37
|
|
|
37
38
|
### What is 'Native' ESM?
|
|
@@ -115,7 +116,7 @@ const { named } = pkg;
|
|
|
115
116
|
|
|
116
117
|
## Troubleshooting ESM Issues
|
|
117
118
|
|
|
118
|
-
If you encounter these errors, the issue is almost certainly with the upstream library. They need to [fix their library](#library-author-guide) to support being imported by Node.
|
|
119
|
+
If you encounter these errors, the issue is almost certainly with the upstream library. They need to [fix their library](/docs/3.x/guide/concepts/esm#library-author-guide) to support being imported by Node.
|
|
119
120
|
|
|
120
121
|
### Transpiling Libraries
|
|
121
122
|
|
|
@@ -161,7 +162,7 @@ const pkg = require('cjs-pkg')
|
|
|
161
162
|
console.log(pkg) // { test: 123 }
|
|
162
163
|
```
|
|
163
164
|
|
|
164
|
-
[Node.js in native ESM mode](https://nodejs.org/api/esm.html#interoperability-with-commonjs), [typescript with `esModuleInterop` enabled](https://www.typescriptlang.org/tsconfig
|
|
165
|
+
[Node.js in native ESM mode](https://nodejs.org/api/esm.html#interoperability-with-commonjs), [typescript with `esModuleInterop` enabled](https://www.typescriptlang.org/tsconfig/#esModuleInterop) and bundlers such as webpack, provide a compatibility mechanism so that we can default import such library.
|
|
165
166
|
This mechanism is often referred to as "interop require default":
|
|
166
167
|
|
|
167
168
|
```js
|
|
@@ -288,7 +289,7 @@ const someFile = await resolvePath('my-lib', { url: import.meta.url })
|
|
|
288
289
|
|
|
289
290
|
### Best Practices
|
|
290
291
|
|
|
291
|
-
- Prefer named exports rather than default export. This helps reduce CJS conflicts. (see [Default exports](#default-exports) section)
|
|
292
|
+
- Prefer named exports rather than default export. This helps reduce CJS conflicts. (see [Default exports](/docs/3.x/guide/concepts/esm#default-exports) section)
|
|
292
293
|
|
|
293
294
|
- Avoid depending on Node.js built-ins and CommonJS or Node.js-only dependencies as much as possible to make your library usable in Browsers and Edge Workers without needing Nitro polyfills.
|
|
294
295
|
|
|
@@ -27,6 +27,10 @@ To enable type-checking at build or development time, install `vue-tsc` and `typ
|
|
|
27
27
|
bun add -D vue-tsc typescript
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
+
```bash [deno]
|
|
31
|
+
deno add -D npm:vue-tsc npm:typescript
|
|
32
|
+
```
|
|
33
|
+
|
|
30
34
|
::
|
|
31
35
|
|
|
32
36
|
Then, run [`nuxt typecheck`](/docs/3.x/api/commands/typecheck) command to check your types:
|
|
@@ -63,6 +67,10 @@ This file contains the recommended basic TypeScript configuration for your proje
|
|
|
63
67
|
Consider using the `imports` section of [nuxt.config](/docs/3.x/api/nuxt-config#imports) to include directories beyond the default ones. This can be useful for auto-importing types which you're using across your app.
|
|
64
68
|
::
|
|
65
69
|
|
|
70
|
+
::warning
|
|
71
|
+
Nuxt relies on this configuration, and [Nuxt modules](/docs/3.x/guide/modules) can extend it as well. For this reason, it is not recommended to modify your `tsconfig.json` file directly, as doing so could overwrite important settings. Instead, extend it via `nuxt.config.ts`. [Learn more about extending the configuration here](/docs/3.x/directory-structure/tsconfig).
|
|
72
|
+
::
|
|
73
|
+
|
|
66
74
|
[Read more about how to extend this configuration](/docs/3.x/directory-structure/tsconfig).
|
|
67
75
|
|
|
68
76
|
::tip{icon="i-lucide-video" to="https://youtu.be/umLI7SlPygY" target="_blank"}
|
|
@@ -80,25 +88,11 @@ Overwriting options such as `"compilerOptions.paths"` with your own configuratio
|
|
|
80
88
|
In case you need to extend options provided by `./.nuxt/tsconfig.json` further, you can use the [`alias` property](/docs/3.x/api/nuxt-config#alias) within your `nuxt.config`. Nuxt will pick them up and extend `./.nuxt/tsconfig.json` accordingly.
|
|
81
89
|
::
|
|
82
90
|
|
|
83
|
-
### Augmenting Types with Project References
|
|
84
|
-
|
|
85
|
-
Since the project is divided into **multiple type contexts**, it's important to **augment types within the correct context** to ensure they are properly recognized.
|
|
86
|
-
|
|
87
|
-
For example, if you want to augment types for the `app` context, the augmentation file should be placed in the `app/` directory.
|
|
88
|
-
|
|
89
|
-
Similarly:
|
|
90
|
-
- For the `server` context, place the augmentation file in the `server/` directory.
|
|
91
|
-
- For types that are **shared between the app and server**, place the file in the `shared/` directory.
|
|
92
|
-
|
|
93
|
-
::warning
|
|
94
|
-
Augmenting types outside of these directories will not be recognized by TypeScript.
|
|
95
|
-
::
|
|
96
|
-
|
|
97
91
|
## Strict Checks
|
|
98
92
|
|
|
99
93
|
TypeScript comes with certain checks to give you more safety and analysis of your program.
|
|
100
94
|
|
|
101
|
-
[Strict checks](https://www.typescriptlang.org/docs/handbook/migrating-from-javascript.html#getting-stricter-checks) are enabled by default in Nuxt to give you greater type safety.
|
|
95
|
+
[Strict checks](https://www.typescriptlang.org/docs/handbook/migrating-from-javascript.html#getting-stricter-checks) are enabled by default in Nuxt when the [`typescript.typeCheck`](/docs/3.x/guide/concepts/typescript#type-checking) option is enabled to give you greater type safety.
|
|
102
96
|
|
|
103
97
|
If you are currently converting your codebase to TypeScript, you may want to temporarily disable strict checks by setting `strict` to `false` in your `nuxt.config`:
|
|
104
98
|
|
|
@@ -8,7 +8,7 @@ description: "Nuxt supports ESLint out of the box"
|
|
|
8
8
|
The recommended approach for Nuxt is to enable ESLint support using the [`@nuxt/eslint`](https://eslint.nuxt.com/packages/module) module, that will setup project-aware ESLint configuration for you.
|
|
9
9
|
|
|
10
10
|
:::callout{icon="i-lucide-lightbulb"}
|
|
11
|
-
The module is designed for the [new ESLint flat config format](https://eslint.org/docs/latest/use/configure/configuration-files
|
|
11
|
+
The module is designed for the [new ESLint flat config format](https://eslint.org/docs/latest/use/configure/configuration-files) which is the [default format since ESLint v9](https://eslint.org/blog/2024/04/eslint-v9.0.0-released/). If you are using the legacy `.eslintrc` config, you will need to [configure manually with `@nuxt/eslint-config`](https://eslint.nuxt.com/packages/config#customizing-the-config). We highly recommend you to migrate over the flat config to be future-proof.
|
|
12
12
|
:::
|
|
13
13
|
|
|
14
14
|
## Quick Setup
|
|
@@ -184,5 +184,5 @@ onMounted(() => {
|
|
|
184
184
|
4. **Avoid side effects in setup**: Move browser-dependent code to `onMounted`
|
|
185
185
|
|
|
186
186
|
::tip
|
|
187
|
-
You can read the [Vue documentation on SSR hydration mismatch](https://vuejs.org/guide/scaling-up/ssr
|
|
187
|
+
You can read the [Vue documentation on SSR hydration mismatch](https://vuejs.org/guide/scaling-up/ssr#hydration-mismatch) for a better understanding of hydration.
|
|
188
188
|
::
|
|
@@ -39,7 +39,7 @@ export default defineNuxtConfig({
|
|
|
39
39
|
})
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
:read-more{title="NuxtLink" to="/docs/api/components/nuxt-link"}
|
|
42
|
+
:read-more{title="NuxtLink" to="/docs/3.x/api/components/nuxt-link"}
|
|
43
43
|
|
|
44
44
|
### Hybrid Rendering
|
|
45
45
|
|
|
@@ -68,7 +68,7 @@ export default defineNuxtConfig({
|
|
|
68
68
|
|
|
69
69
|
Nuxt server will automatically register corresponding middleware and wrap routes with cache handlers using Nitro caching layer.
|
|
70
70
|
|
|
71
|
-
:read-more{title="Hybrid rendering" to="/docs/guide/concepts/rendering#hybrid-rendering"}
|
|
71
|
+
:read-more{title="Hybrid rendering" to="/docs/3.x/guide/concepts/rendering#hybrid-rendering"}
|
|
72
72
|
|
|
73
73
|
### Lazy Loading Components
|
|
74
74
|
|
|
@@ -90,7 +90,7 @@ const show = ref(false)
|
|
|
90
90
|
|
|
91
91
|
By using the Lazy prefix you can delay loading the component code until the right moment, which can be helpful for optimizing your JavaScript bundle size.
|
|
92
92
|
|
|
93
|
-
:read-more{title="Lazy loading components" to="/docs/
|
|
93
|
+
:read-more{title="Lazy loading components" to="/docs/3.x/directory-structure/components#dynamic-imports"}
|
|
94
94
|
|
|
95
95
|
### Lazy Hydration
|
|
96
96
|
|
|
@@ -106,13 +106,13 @@ It is not always necessary to hydrate (or make interactive) all the components o
|
|
|
106
106
|
|
|
107
107
|
To optimize your app, you may want to delay the hydration of some components until they're visible, or until the browser is done with more important tasks.
|
|
108
108
|
|
|
109
|
-
:read-more{title="Lazy hydration" to="/docs/
|
|
109
|
+
:read-more{title="Lazy hydration" to="/docs/3.x/directory-structure/components#delayed-or-lazy-hydration"}
|
|
110
110
|
|
|
111
111
|
### Fetching data
|
|
112
112
|
|
|
113
113
|
To avoid fetching same data twice (once on the server and once on client) Nuxt provides [`useFetch`](/docs/3.x/api/composables/use-fetch) and [`useAsyncData`](/docs/3.x/api/composables/use-async-data). They ensure that if an API call is made on the server, the data is forwarded to the client in the payload instead of being fetched again.
|
|
114
114
|
|
|
115
|
-
:read-more{title="Data fetching" to="/docs/getting-started/data-fetching"}
|
|
115
|
+
:read-more{title="Data fetching" to="/docs/3.x/getting-started/data-fetching"}
|
|
116
116
|
|
|
117
117
|
## Core Nuxt Modules
|
|
118
118
|
|