Skip to content

Commit e07642a

Browse files
committed
more improvements
1 parent 1bac259 commit e07642a

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

docs/3.guide/1.concepts/2.vuejs-development.md renamed to docs/3.guide/1.concepts/10.vuejs-development.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: 'Vue.js Development'
33
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
45
---
56

67
Nuxt integrates Vue 3, the new major release of Vue that enables new patterns for Nuxt users.

docs/3.guide/1.concepts/10.nuxt-lifecycle.md renamed to docs/3.guide/1.concepts/2.nuxt-lifecycle.md

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ description: "Understanding the lifecycle of Nuxt applications can help you gain
55

66
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.
77

8-
## Server
8+
## Server lifecycle
99

1010
On the server, the following steps are executed for every initial request to your application:
1111

12-
### Step 1: Setup Nitro Server and Nitro Plugins (Once)
12+
::steps
13+
### Server plugins :badge[once]{color="info" class="align-middle"}
1314

1415
Nuxt is powered by [Nitro](https://nitro.build/), a modern server engine.
1516

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/4.x/directory-structure/server#server-plugins) directory. These plugins can:
1718
- Capture and handle application-wide errors.
1819
- Register hooks that execute when Nitro shuts down.
1920
- Register hooks for request lifecycle events, such as modifying responses.
@@ -24,7 +25,7 @@ Nitro plugins are executed only once when the server starts. In a serverless env
2425

2526
:read-more{to="/docs/4.x/guide/directory-structure/server#server-plugins"}
2627

27-
### Step 2: Nitro Server Middleware
28+
### Server middleware
2829

2930
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.
3031

@@ -34,9 +35,9 @@ Returning a value from middleware will terminate the request and send the return
3435

3536
:read-more{to="/docs/4.x/guide/directory-structure/server#server-middleware"}
3637

37-
### Step 3: Initialize Nuxt and Execute Nuxt App Plugins
38+
### App plugins
3839

39-
The Vue and Nuxt instances are created first. Afterward, Nuxt executes its server plugins. This includes:
40+
The Vue and Nuxt instances are created first. Afterward, Nuxt executes its app plugins. This includes:
4041
- Built-in plugins, such as Vue Router and `unhead`.
4142
- Custom plugins located in the `app/plugins/` directory, including those without a suffix (e.g., `myPlugin.ts`) and those with the `.server` suffix (e.g., `myServerPlugin.server.ts`).
4243

@@ -48,7 +49,7 @@ After this step, Nuxt calls the [`app:created`](/docs/4.x/api/advanced/hooks#app
4849

4950
:read-more{to="/docs/4.x/guide/directory-structure/app/plugins"}
5051

51-
### Step 4: Route Validation
52+
### Route validation
5253

5354
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.
5455

@@ -59,7 +60,7 @@ For more information, see the [Route Validation documentation](/docs/4.x/getting
5960

6061
:read-more{to="/docs/4.x/getting-started/routing#route-validation"}
6162

62-
### Step 5: Execute Nuxt App Middleware
63+
### App middleware
6364

6465
Middleware allows you to run code before navigating to a particular route. It is often used for tasks such as authentication, redirection, or logging.
6566

@@ -76,7 +77,7 @@ Any redirection on the server will result in a `Location:` header being sent to
7677

7778
:read-more{to="/docs/4.x/guide/directory-structure/app/middleware"}
7879

79-
### Step 6: Render Page and Components
80+
### Page and components
8081

8182
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.
8283

@@ -94,7 +95,7 @@ You should avoid code that produces side effects that need cleanup in root scope
9495
Watch a video from Daniel Roe explaining Server Rendering and Global State.
9596
::
9697

97-
### Step 7: Generate HTML Output
98+
### HTML Output
9899

99100
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.
100101

@@ -106,11 +107,15 @@ After rendering the Vue application to HTML, Nuxt calls the [`app:rendered`](/do
106107
Before finalizing and sending the HTML, Nitro will call the [`render:html`](/docs/4.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.
107108
::
108109

109-
## Client (browser)
110+
::
111+
112+
## Client lifecycle
110113

111114
This part of the lifecycle is fully executed in the browser, no matter which Nuxt mode you've chosen.
112115

113-
### Step 1: Initialize Nuxt and Execute Nuxt App Plugins
116+
::steps
117+
118+
### App plugins
114119

115120
This step is similar to the server-side execution and includes both built-in and custom plugins.
116121

@@ -122,17 +127,17 @@ After this step, Nuxt calls the [`app:created`](/docs/4.x/api/advanced/hooks#app
122127

123128
:read-more{to="/docs/4.x/guide/directory-structure/app/plugins"}
124129

125-
### Step 2: Route Validation
130+
### Route validation
126131

127132
This step is the same as the server-side execution and includes the `validate` method if defined in the `definePageMeta` function.
128133

129-
### Step 3: Execute Nuxt App Middleware
134+
### App middleware
130135

131136
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.
132137

133138
:read-more{to="/docs/4.x/guide/directory-structure/app/middleware#when-middleware-runs"}
134139

135-
### Step 4: Mount Vue Application and Hydration
140+
### Mount Vue app and hydrate
136141

137142
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/4.x/guide/directory-structure/app/components#server-components)), matches each component to its corresponding DOM nodes, and attaches DOM event listeners.
138143

@@ -146,6 +151,8 @@ Before mounting the Vue application, Nuxt calls the [`app:beforeMount`](/docs/4.
146151
After mounting the Vue application, Nuxt calls the [`app:mounted`](/docs/4.x/api/advanced/hooks#app-hooks-runtime) hook.
147152
::
148153

149-
### Step 5: Vue Lifecycle
154+
### Vue lifecycle
150155

151156
Unlike on the server, the browser executes the full [Vue lifecycle](https://vuejs.org/guide/essentials/lifecycle).
157+
158+
::

0 commit comments

Comments
 (0)