@nuxt/docs 3.17.4 → 3.17.6

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.
Files changed (63) hide show
  1. package/1.getting-started/01.introduction.md +3 -3
  2. package/1.getting-started/03.configuration.md +1 -1
  3. package/1.getting-started/07.routing.md +1 -1
  4. package/1.getting-started/10.data-fetching.md +1 -1
  5. package/1.getting-started/11.state-management.md +1 -1
  6. package/1.getting-started/12.error-handling.md +1 -1
  7. package/1.getting-started/13.server.md +1 -1
  8. package/1.getting-started/15.prerendering.md +8 -8
  9. package/1.getting-started/16.deployment.md +2 -2
  10. package/1.getting-started/18.upgrade.md +7 -7
  11. package/2.guide/1.concepts/10.nuxt-lifecycle.md +14 -4
  12. package/2.guide/1.concepts/3.rendering.md +2 -2
  13. package/2.guide/1.concepts/4.server-engine.md +2 -2
  14. package/2.guide/1.concepts/5.modules.md +1 -1
  15. package/2.guide/1.concepts/8.typescript.md +6 -6
  16. package/2.guide/1.concepts/9.code-style.md +1 -1
  17. package/2.guide/2.directory-structure/1.composables.md +1 -1
  18. package/2.guide/2.directory-structure/1.content.md +1 -1
  19. package/2.guide/2.directory-structure/1.pages.md +5 -1
  20. package/2.guide/2.directory-structure/1.plugins.md +0 -4
  21. package/2.guide/2.directory-structure/1.server.md +3 -3
  22. package/2.guide/2.directory-structure/2.env.md +4 -4
  23. package/2.guide/3.going-further/1.experimental-features.md +2 -1
  24. package/2.guide/3.going-further/1.internals.md +2 -2
  25. package/2.guide/3.going-further/10.runtime-config.md +1 -1
  26. package/2.guide/3.going-further/11.nightly-release-channel.md +4 -8
  27. package/2.guide/3.going-further/3.modules.md +2 -4
  28. package/2.guide/3.going-further/9.debugging.md +1 -5
  29. package/2.guide/4.recipes/4.sessions-and-authentication.md +3 -3
  30. package/3.api/1.components/10.nuxt-picture.md +1 -1
  31. package/3.api/1.components/4.nuxt-link.md +4 -0
  32. package/3.api/1.components/9.nuxt-img.md +1 -1
  33. package/3.api/2.composables/on-prehydrate.md +21 -12
  34. package/3.api/2.composables/use-async-data.md +1 -1
  35. package/3.api/2.composables/use-cookie.md +67 -125
  36. package/3.api/2.composables/use-error.md +30 -7
  37. package/3.api/2.composables/use-fetch.md +70 -73
  38. package/3.api/2.composables/use-nuxt-app.md +1 -1
  39. package/3.api/2.composables/use-preview-mode.md +3 -3
  40. package/3.api/3.utils/define-nuxt-plugin.md +102 -0
  41. package/3.api/4.commands/add.md +20 -20
  42. package/3.api/4.commands/analyze.md +2 -2
  43. package/3.api/4.commands/build-module.md +2 -2
  44. package/3.api/4.commands/build.md +2 -2
  45. package/3.api/4.commands/cleanup.md +2 -2
  46. package/3.api/4.commands/dev.md +3 -3
  47. package/3.api/4.commands/devtools.md +3 -3
  48. package/3.api/4.commands/generate.md +3 -3
  49. package/3.api/4.commands/info.md +2 -2
  50. package/3.api/4.commands/init.md +3 -3
  51. package/3.api/4.commands/module.md +8 -8
  52. package/3.api/4.commands/prepare.md +2 -2
  53. package/3.api/4.commands/preview.md +3 -3
  54. package/3.api/4.commands/typecheck.md +2 -2
  55. package/3.api/4.commands/upgrade.md +2 -2
  56. package/3.api/5.kit/13.logging.md +1 -1
  57. package/3.api/5.kit/7.pages.md +1 -1
  58. package/3.api/6.advanced/1.hooks.md +8 -8
  59. package/5.community/4.contribution.md +1 -1
  60. package/5.community/6.roadmap.md +17 -12
  61. package/5.community/7.changelog.md +1 -1
  62. package/7.migration/2.configuration.md +2 -2
  63. package/package.json +1 -1
@@ -0,0 +1,102 @@
1
+ ---
2
+ title: "defineNuxtPlugin"
3
+ description: defineNuxtPlugin() is a helper function for creating Nuxt plugins.
4
+ links:
5
+ - label: Source
6
+ icon: i-simple-icons-github
7
+ to: https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/nuxt.ts
8
+ size: xs
9
+ ---
10
+
11
+ `defineNuxtPlugin` is a helper function for creating Nuxt plugins with enhanced functionality and type safety. This utility normalizes different plugin formats into a consistent structure that works seamlessly within Nuxt's plugin system.
12
+
13
+ ```ts twoslash [plugins/hello.ts]
14
+ export default defineNuxtPlugin((nuxtApp) => {
15
+ // Doing something with nuxtApp
16
+ })
17
+ ```
18
+
19
+ :read-more{to="/docs/guide/directory-structure/plugins#creating-plugins"}
20
+
21
+ ## Type
22
+
23
+ ```ts
24
+ defineNuxtPlugin<T extends Record<string, unknown>>(plugin: Plugin<T> | ObjectPlugin<T>): Plugin<T> & ObjectPlugin<T>
25
+
26
+ type Plugin<T> = (nuxt: [NuxtApp](/docs/guide/going-further/internals#the-nuxtapp-interface)) => Promise<void> | Promise<{ provide?: T }> | void | { provide?: T }
27
+
28
+ interface ObjectPlugin<T> {
29
+ name?: string
30
+ enforce?: 'pre' | 'default' | 'post'
31
+ dependsOn?: string[]
32
+ order?: number
33
+ parallel?: boolean
34
+ setup?: Plugin<T>
35
+ hooks?: Partial<[RuntimeNuxtHooks](/docs/api/advanced/hooks#app-hooks-runtime)>
36
+ env?: {
37
+ islands?: boolean
38
+ }
39
+ }
40
+ ```
41
+
42
+ ## Parameters
43
+
44
+ **plugin**: A plugin can be defined in two ways:
45
+ 1. **Function Plugin**: A function that receives the [`NuxtApp`](/docs/guide/going-further/internals#the-nuxtapp-interface) instance and can return a promise with an potential object with a [`provide`](/docs/guide/directory-structure/plugins#providing-helpers) property if you want to provide a helper on [`NuxtApp`](/docs/guide/going-further/internals#the-nuxtapp-interface) instance.
46
+ 2. **Object Plugin**: An object that can include various properties to configure the plugin's behavior, such as `name`, `enforce`, `dependsOn`, `order`, `parallel`, `setup`, `hooks`, and `env`.
47
+
48
+ | Property | Type | Required | Description |
49
+ | ------------------ | -------------------------------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
50
+ | `name` | `string` | `false` | Optional name for the plugin, useful for debugging and dependency management. |
51
+ | `enforce` | `'pre'` \| `'default'` \| `'post'` | `false` | Controls when the plugin runs relative to other plugins. |
52
+ | `dependsOn` | `string[]` | `false` | Array of plugin names this plugin depends on. Ensures proper execution order. |
53
+ | `order` | `number` | `false` | This allows more granular control over plugin order and should only be used by advanced users. **It overrides the value of `enforce` and is used to sort plugins.** |
54
+ | `parallel` | `boolean` | `false` | Whether to execute the plugin in parallel with other parallel plugins. |
55
+ | `setup` | `Plugin<T>`{lang="ts"} | `false` | The main plugin function, equivalent to a function plugin. |
56
+ | `hooks` | `Partial<RuntimeNuxtHooks>`{lang="ts"} | `false` | Nuxt app runtime hooks to register directly. |
57
+ | `env` | `{ islands?: boolean }`{lang="ts"} | `false` | Set this value to `false` if you don't want the plugin to run when rendering server-only or island components. |
58
+
59
+ :video-accordion{title="Watch a video from Alexander Lichter about the Object Syntax for Nuxt plugins" videoId="2aXZyXB1QGQ"}
60
+
61
+ ## Examples
62
+
63
+ ### Basic Usage
64
+
65
+ The example below demonstrates a simple plugin that adds global functionality:
66
+
67
+ ```ts twoslash [plugins/hello.ts]
68
+ export default defineNuxtPlugin((nuxtApp) => {
69
+ // Add a global method
70
+ return {
71
+ provide: {
72
+ hello: (name: string) => `Hello ${name}!`
73
+ }
74
+ }
75
+ })
76
+ ```
77
+
78
+ ### Object Syntax Plugin
79
+
80
+ The example below shows the object syntax with advanced configuration:
81
+
82
+ ```ts twoslash [plugins/advanced.ts]
83
+ export default defineNuxtPlugin({
84
+ name: 'my-plugin',
85
+ enforce: 'pre',
86
+ async setup (nuxtApp) {
87
+ // Plugin setup logic
88
+ const data = await $fetch('/api/config')
89
+
90
+ return {
91
+ provide: {
92
+ config: data
93
+ }
94
+ }
95
+ },
96
+ hooks: {
97
+ 'app:created'() {
98
+ console.log('App created!')
99
+ }
100
+ },
101
+ })
102
+ ```
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: "nuxi add"
2
+ title: "nuxt add"
3
3
  description: "Scaffold an entity into your Nuxt application."
4
4
  links:
5
5
  - label: Source
@@ -10,7 +10,7 @@ links:
10
10
 
11
11
  <!--add-cmd-->
12
12
  ```bash [Terminal]
13
- npx nuxi add <TEMPLATE> <NAME> [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--force]
13
+ npx nuxt add <TEMPLATE> <NAME> [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--force]
14
14
  ```
15
15
  <!--/add-cmd-->
16
16
 
@@ -39,74 +39,74 @@ Some templates support additional modifier flags to add a suffix (like `.client`
39
39
 
40
40
  ```bash [Terminal]
41
41
  # Generates `/plugins/sockets.client.ts`
42
- npx nuxi add plugin sockets --client
42
+ npx nuxt add plugin sockets --client
43
43
  ```
44
44
 
45
- ## `nuxi add component`
45
+ ## `nuxt add component`
46
46
 
47
47
  * Modifier flags: `--mode client|server` or `--client` or `--server`
48
48
 
49
49
  ```bash [Terminal]
50
50
  # Generates `components/TheHeader.vue`
51
- npx nuxi add component TheHeader
51
+ npx nuxt add component TheHeader
52
52
  ```
53
53
 
54
- ## `nuxi add composable`
54
+ ## `nuxt add composable`
55
55
 
56
56
  ```bash [Terminal]
57
57
  # Generates `composables/foo.ts`
58
- npx nuxi add composable foo
58
+ npx nuxt add composable foo
59
59
  ```
60
60
 
61
- ## `nuxi add layout`
61
+ ## `nuxt add layout`
62
62
 
63
63
  ```bash [Terminal]
64
64
  # Generates `layouts/custom.vue`
65
- npx nuxi add layout custom
65
+ npx nuxt add layout custom
66
66
  ```
67
67
 
68
- ## `nuxi add plugin`
68
+ ## `nuxt add plugin`
69
69
 
70
70
  * Modifier flags: `--mode client|server` or `--client`or `--server`
71
71
 
72
72
  ```bash [Terminal]
73
73
  # Generates `plugins/analytics.ts`
74
- npx nuxi add plugin analytics
74
+ npx nuxt add plugin analytics
75
75
  ```
76
76
 
77
- ## `nuxi add page`
77
+ ## `nuxt add page`
78
78
 
79
79
  ```bash [Terminal]
80
80
  # Generates `pages/about.vue`
81
- npx nuxi add page about
81
+ npx nuxt add page about
82
82
  ```
83
83
 
84
84
  ```bash [Terminal]
85
85
  # Generates `pages/category/[id].vue`
86
- npx nuxi add page "category/[id]"
86
+ npx nuxt add page "category/[id]"
87
87
  ```
88
88
 
89
- ## `nuxi add middleware`
89
+ ## `nuxt add middleware`
90
90
 
91
91
  * Modifier flags: `--global`
92
92
 
93
93
  ```bash [Terminal]
94
94
  # Generates `middleware/auth.ts`
95
- npx nuxi add middleware auth
95
+ npx nuxt add middleware auth
96
96
  ```
97
97
 
98
- ## `nuxi add api`
98
+ ## `nuxt add api`
99
99
 
100
100
  * Modifier flags: `--method` (can accept `connect`, `delete`, `get`, `head`, `options`, `patch`, `post`, `put` or `trace`) or alternatively you can directly use `--get`, `--post`, etc.
101
101
 
102
102
  ```bash [Terminal]
103
103
  # Generates `server/api/hello.ts`
104
- npx nuxi add api hello
104
+ npx nuxt add api hello
105
105
  ```
106
106
 
107
- ## `nuxi add layer`
107
+ ## `nuxt add layer`
108
108
 
109
109
  ```bash [Terminal]
110
110
  # Generates `layers/subscribe/nuxt.config.ts`
111
- npx nuxi add layer subscribe
111
+ npx nuxt add layer subscribe
112
112
  ```
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: "nuxi analyze"
2
+ title: "nuxt analyze"
3
3
  description: "Analyze the production bundle or your Nuxt application."
4
4
  links:
5
5
  - label: Source
@@ -10,7 +10,7 @@ links:
10
10
 
11
11
  <!--analyze-cmd-->
12
12
  ```bash [Terminal]
13
- npx nuxi analyze [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--dotenv] [--name=<name>] [--no-serve]
13
+ npx nuxt analyze [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--dotenv] [--name=<name>] [--no-serve]
14
14
  ```
15
15
  <!--/analyze-cmd-->
16
16
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: 'nuxi build-module'
2
+ title: 'nuxt build-module'
3
3
  description: 'Nuxt command to build your Nuxt module before publishing.'
4
4
  links:
5
5
  - label: Source
@@ -10,7 +10,7 @@ links:
10
10
 
11
11
  <!--build-module-cmd-->
12
12
  ```bash [Terminal]
13
- npx nuxi build-module [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--build] [--stub] [--sourcemap] [--prepare]
13
+ npx nuxt build-module [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--build] [--stub] [--sourcemap] [--prepare]
14
14
  ```
15
15
  <!--/build-module-cmd-->
16
16
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: "nuxi build"
2
+ title: "nuxt build"
3
3
  description: "Build your Nuxt application."
4
4
  links:
5
5
  - label: Source
@@ -10,7 +10,7 @@ links:
10
10
 
11
11
  <!--build-cmd-->
12
12
  ```bash [Terminal]
13
- npx nuxi build [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--prerender] [--preset] [--dotenv] [--envName]
13
+ npx nuxt build [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--prerender] [--preset] [--dotenv] [--envName]
14
14
  ```
15
15
  <!--/build-cmd-->
16
16
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: 'nuxi cleanup'
2
+ title: 'nuxt cleanup'
3
3
  description: 'Remove common generated Nuxt files and caches.'
4
4
  links:
5
5
  - label: Source
@@ -10,7 +10,7 @@ links:
10
10
 
11
11
  <!--cleanup-cmd-->
12
12
  ```bash [Terminal]
13
- npx nuxi cleanup [ROOTDIR] [--cwd=<directory>]
13
+ npx nuxt cleanup [ROOTDIR] [--cwd=<directory>]
14
14
  ```
15
15
  <!--/cleanup-cmd-->
16
16
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: 'nuxi dev'
2
+ title: 'nuxt dev'
3
3
  description: The dev command starts a development server with hot module replacement at http://localhost:3000
4
4
  links:
5
5
  - label: Source
@@ -10,7 +10,7 @@ links:
10
10
 
11
11
  <!--dev-cmd-->
12
12
  ```bash [Terminal]
13
- npx nuxi dev [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--dotenv] [--envName] [--no-clear] [--no-fork] [-p, --port] [-h, --host] [--clipboard] [-o, --open] [--https] [--publicURL] [--qr] [--public] [--tunnel] [--sslCert] [--sslKey]
13
+ npx nuxt dev [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--dotenv] [--envName] [--no-clear] [--no-fork] [-p, --port] [-h, --host] [--clipboard] [-o, --open] [--https] [--publicURL] [--qr] [--public] [--tunnel] [--sslCert] [--sslKey]
14
14
  ```
15
15
  <!--/dev-cmd-->
16
16
 
@@ -50,7 +50,7 @@ Option | Default | Description
50
50
 
51
51
  The port and host can also be set via NUXT_PORT, PORT, NUXT_HOST or HOST environment variables.
52
52
 
53
- Additionally to the above options, `nuxi` can pass options through to `listhen`, e.g. `--no-qr` to turn off the dev server QR code. You can find the list of `listhen` options in the [unjs/listhen](https://github.com/unjs/listhen) docs.
53
+ Additionally to the above options, `@nuxt/cli` can pass options through to `listhen`, e.g. `--no-qr` to turn off the dev server QR code. You can find the list of `listhen` options in the [unjs/listhen](https://github.com/unjs/listhen) docs.
54
54
 
55
55
  This command sets `process.env.NODE_ENV` to `development`.
56
56
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: "nuxi devtools"
2
+ title: "nuxt devtools"
3
3
  description: The devtools command allows you to enable or disable Nuxt DevTools on a per-project basis.
4
4
  links:
5
5
  - label: Source
@@ -10,11 +10,11 @@ links:
10
10
 
11
11
  <!--devtools-cmd-->
12
12
  ```bash [Terminal]
13
- npx nuxi devtools <COMMAND> [ROOTDIR] [--cwd=<directory>]
13
+ npx nuxt devtools <COMMAND> [ROOTDIR] [--cwd=<directory>]
14
14
  ```
15
15
  <!--/devtools-cmd-->
16
16
 
17
- Running `nuxi devtools enable` will install the Nuxt DevTools globally, and also enable it within the particular project you are using. It is saved as a preference in your user-level `.nuxtrc`. If you want to remove devtools support for a particular project, you can run `nuxi devtools disable`.
17
+ Running `nuxt devtools enable` will install the Nuxt DevTools globally, and also enable it within the particular project you are using. It is saved as a preference in your user-level `.nuxtrc`. If you want to remove devtools support for a particular project, you can run `nuxt devtools disable`.
18
18
 
19
19
  ## Arguments
20
20
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: "nuxi generate"
2
+ title: "nuxt generate"
3
3
  description: Pre-renders every route of the application and stores the result in plain HTML files.
4
4
  links:
5
5
  - label: Source
@@ -10,11 +10,11 @@ links:
10
10
 
11
11
  <!--generate-cmd-->
12
12
  ```bash [Terminal]
13
- npx nuxi generate [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--preset] [--dotenv] [--envName]
13
+ npx nuxt generate [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--preset] [--dotenv] [--envName]
14
14
  ```
15
15
  <!--/generate-cmd-->
16
16
 
17
- The `generate` command pre-renders every route of your application and stores the result in plain HTML files that you can deploy on any static hosting services. The command triggers the `nuxi build` command with the `prerender` argument set to `true`
17
+ The `generate` command pre-renders every route of your application and stores the result in plain HTML files that you can deploy on any static hosting services. The command triggers the `nuxt build` command with the `prerender` argument set to `true`
18
18
 
19
19
  ## Arguments
20
20
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: "nuxi info"
2
+ title: "nuxt info"
3
3
  description: The info command logs information about the current or specified Nuxt project.
4
4
  links:
5
5
  - label: Source
@@ -10,7 +10,7 @@ links:
10
10
 
11
11
  <!--info-cmd-->
12
12
  ```bash [Terminal]
13
- npx nuxi info [ROOTDIR] [--cwd=<directory>]
13
+ npx nuxt info [ROOTDIR] [--cwd=<directory>]
14
14
  ```
15
15
  <!--/info-cmd-->
16
16
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: "nuxi init"
2
+ title: "create nuxt"
3
3
  description: The init command initializes a fresh Nuxt project.
4
4
  links:
5
5
  - label: Source
@@ -10,11 +10,11 @@ links:
10
10
 
11
11
  <!--init-cmd-->
12
12
  ```bash [Terminal]
13
- npx nuxi init [DIR] [--cwd=<directory>] [-t, --template] [-f, --force] [--offline] [--preferOffline] [--no-install] [--gitInit] [--shell] [--packageManager]
13
+ npm create nuxt@latest [DIR] [--cwd=<directory>] [-t, --template] [-f, --force] [--offline] [--preferOffline] [--no-install] [--gitInit] [--shell] [--packageManager]
14
14
  ```
15
15
  <!--/init-cmd-->
16
16
 
17
- The `init` command initializes a fresh Nuxt project using [unjs/giget](https://github.com/unjs/giget).
17
+ The `create-nuxt` command initializes a fresh Nuxt project using [unjs/giget](https://github.com/unjs/giget).
18
18
 
19
19
  ## Arguments
20
20
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: "nuxi module"
2
+ title: "nuxt module"
3
3
  description: "Search and add modules to your Nuxt application with the command line."
4
4
  links:
5
5
  - label: Source
@@ -8,13 +8,13 @@ links:
8
8
  size: xs
9
9
  ---
10
10
 
11
- Nuxi provides a few utilities to work with [Nuxt modules](/modules) seamlessly.
11
+ Nuxt provides a few utilities to work with [Nuxt modules](/modules) seamlessly.
12
12
 
13
- ## nuxi module add
13
+ ## nuxt module add
14
14
 
15
15
  <!--module-add-cmd-->
16
16
  ```bash [Terminal]
17
- npx nuxi module add <MODULENAME> [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--skipInstall] [--skipConfig] [--dev]
17
+ npx nuxt module add <MODULENAME> [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--skipInstall] [--skipConfig] [--dev]
18
18
  ```
19
19
  <!--/module-add-cmd-->
20
20
 
@@ -47,14 +47,14 @@ When running the command, it will:
47
47
  Installing the [`Pinia`](/modules/pinia) module
48
48
 
49
49
  ```bash [Terminal]
50
- npx nuxi module add pinia
50
+ npx nuxt module add pinia
51
51
  ```
52
52
 
53
- ## nuxi module search
53
+ ## nuxt module search
54
54
 
55
55
  <!--module-search-cmd-->
56
56
  ```bash [Terminal]
57
- npx nuxi module search <QUERY> [--cwd=<directory>] [--nuxtVersion=<2|3>]
57
+ npx nuxt module search <QUERY> [--cwd=<directory>] [--nuxtVersion=<2|3>]
58
58
  ```
59
59
  <!--/module-search-cmd-->
60
60
 
@@ -80,5 +80,5 @@ The command searches for Nuxt modules matching your query that are compatible wi
80
80
  **Example:**
81
81
 
82
82
  ```bash [Terminal]
83
- npx nuxi module search pinia
83
+ npx nuxt module search pinia
84
84
  ```
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: 'nuxi prepare'
2
+ title: 'nuxt prepare'
3
3
  description: The prepare command creates a .nuxt directory in your application and generates types.
4
4
  links:
5
5
  - label: Source
@@ -10,7 +10,7 @@ links:
10
10
 
11
11
  <!--prepare-cmd-->
12
12
  ```bash [Terminal]
13
- npx nuxi prepare [ROOTDIR] [--dotenv] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--envName]
13
+ npx nuxt prepare [ROOTDIR] [--dotenv] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--envName]
14
14
  ```
15
15
  <!--/prepare-cmd-->
16
16
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: "nuxi preview"
2
+ title: "nuxt preview"
3
3
  description: The preview command starts a server to preview your application after the build command.
4
4
  links:
5
5
  - label: Source
@@ -10,7 +10,7 @@ links:
10
10
 
11
11
  <!--preview-cmd-->
12
12
  ```bash [Terminal]
13
- npx nuxi preview [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--envName] [--dotenv] [-p, --port]
13
+ npx nuxt preview [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--envName] [--dotenv] [-p, --port]
14
14
  ```
15
15
  <!--/preview-cmd-->
16
16
 
@@ -39,5 +39,5 @@ Option | Default | Description
39
39
  This command sets `process.env.NODE_ENV` to `production`. To override, define `NODE_ENV` in a `.env` file or as command-line argument.
40
40
 
41
41
  ::note
42
- For convenience, in preview mode, your [`.env`](/docs/guide/directory-structure/env) file will be loaded into `process.env`. (However, in production you will need to ensure your environment variables are set yourself.)
42
+ For convenience, in preview mode, your [`.env`](/docs/guide/directory-structure/env) file will be loaded into `process.env`. (However, in production you will need to ensure your environment variables are set yourself. For example, with Node.js 20+ you could do this by running `node --env-file .env .output/server/index.mjs` to start your server.)
43
43
  ::
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: "nuxi typecheck"
2
+ title: "nuxt typecheck"
3
3
  description: The typecheck command runs vue-tsc to check types throughout your app.
4
4
  links:
5
5
  - label: Source
@@ -10,7 +10,7 @@ links:
10
10
 
11
11
  <!--typecheck-cmd-->
12
12
  ```bash [Terminal]
13
- npx nuxi typecheck [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>]
13
+ npx nuxt typecheck [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>]
14
14
  ```
15
15
  <!--/typecheck-cmd-->
16
16
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: "nuxi upgrade"
2
+ title: "nuxt upgrade"
3
3
  description: The upgrade command upgrades Nuxt to the latest version.
4
4
  links:
5
5
  - label: Source
@@ -10,7 +10,7 @@ links:
10
10
 
11
11
  <!--upgrade-cmd-->
12
12
  ```bash [Terminal]
13
- npx nuxi upgrade [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--dedupe] [-f, --force] [-ch, --channel=<stable|nightly>]
13
+ npx nuxt upgrade [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--dedupe] [-f, --force] [-ch, --channel=<stable|nightly>]
14
14
  ```
15
15
  <!--/upgrade-cmd-->
16
16
 
@@ -36,7 +36,7 @@ function useLogger (tag?: string, options?: Partial<ConsolaOptions>): ConsolaIns
36
36
 
37
37
  ### Parameters
38
38
 
39
- **`tag`**: A tag to suffix all log messages with.
39
+ **`tag`**: A tag to suffix all log messages with, displayed on the right near the timestamp.
40
40
 
41
41
  **`options`**: Consola configuration options.
42
42
 
@@ -149,7 +149,7 @@ export default defineNuxtModule({
149
149
 
150
150
  addRouteMiddleware({
151
151
  name: 'auth',
152
- path: resolve('runtime/auth.ts'),
152
+ path: resolve('runtime/auth'),
153
153
  global: true,
154
154
  }, { prepend: true })
155
155
  },
@@ -68,7 +68,7 @@ Hook | Arguments | Description
68
68
  `nitro:build:public-assets` | `nitro` | Called after copying public assets. Allows modifying public assets before Nitro server is built.
69
69
  `prerender:routes` | `ctx` | Allows extending the routes to be pre-rendered.
70
70
  `build:error` | `error` | Called when an error occurs at build time.
71
- `prepare:types` | `options` | Called before Nuxi writes `.nuxt/tsconfig.json` and `.nuxt/nuxt.d.ts`, allowing addition of custom references and declarations in `nuxt.d.ts`, or directly modifying the options in `tsconfig.json`
71
+ `prepare:types` | `options` | Called before `@nuxt/cli` writes `.nuxt/tsconfig.json` and `.nuxt/nuxt.d.ts`, allowing addition of custom references and declarations in `nuxt.d.ts`, or directly modifying the options in `tsconfig.json`
72
72
  `listen` | `listenerServer, listener` | Called when the dev server is loading.
73
73
  `schema:extend` | `schemas` | Allows extending default schemas.
74
74
  `schema:resolved` | `schema` | Allows extending resolved schema.
@@ -95,11 +95,11 @@ See [Nitro](https://nitro.build/guide/plugins#available-hooks) for all available
95
95
  Hook | Arguments | Description | Types
96
96
  -----------------------|-----------------------|--------------------------------------|------------------
97
97
  `dev:ssr-logs` | `{ path, logs }` | Server | Called at the end of a request cycle with an array of server-side logs.
98
- `render:response` | `response, { event }` | Called before sending the response. | [response](https://github.com/nuxt/nuxt/blob/71ef8bd3ff207fd51c2ca18d5a8c7140476780c7/packages/nuxt/src/core/runtime/nitro/renderer.ts#L24), [event](https://github.com/unjs/h3/blob/f6ceb5581043dc4d8b6eab91e9be4531e0c30f8e/src/types.ts#L38)
99
- `render:html` | `html, { event }` | Called before constructing the HTML. | [html](https://github.com/nuxt/nuxt/blob/71ef8bd3ff207fd51c2ca18d5a8c7140476780c7/packages/nuxt/src/core/runtime/nitro/renderer.ts#L15), [event](https://github.com/unjs/h3/blob/f6ceb5581043dc4d8b6eab91e9be4531e0c30f8e/src/types.ts#L38)
100
- `render:island` | `islandResponse, { event, islandContext }` | Called before constructing the island HTML. | [islandResponse](https://github.com/nuxt/nuxt/blob/e50cabfed1984c341af0d0c056a325a8aec26980/packages/nuxt/src/core/runtime/nitro/renderer.ts#L28), [event](https://github.com/unjs/h3/blob/f6ceb5581043dc4d8b6eab91e9be4531e0c30f8e/src/types.ts#L38), [islandContext](https://github.com/nuxt/nuxt/blob/e50cabfed1984c341af0d0c056a325a8aec26980/packages/nuxt/src/core/runtime/nitro/renderer.ts#L38)
98
+ `render:response` | `response, { event }` | Called before sending the response. | [response](https://github.com/nuxt/nuxt/blob/71ef8bd3ff207fd51c2ca18d5a8c7140476780c7/packages/nuxt/src/core/runtime/nitro/renderer.ts#L24), [event](https://github.com/h3js/h3/blob/f6ceb5581043dc4d8b6eab91e9be4531e0c30f8e/src/types.ts#L38)
99
+ `render:html` | `html, { event }` | Called before constructing the HTML. | [html](https://github.com/nuxt/nuxt/blob/71ef8bd3ff207fd51c2ca18d5a8c7140476780c7/packages/nuxt/src/core/runtime/nitro/renderer.ts#L15), [event](https://github.com/h3js/h3/blob/f6ceb5581043dc4d8b6eab91e9be4531e0c30f8e/src/types.ts#L38)
100
+ `render:island` | `islandResponse, { event, islandContext }` | Called before constructing the island HTML. | [islandResponse](https://github.com/nuxt/nuxt/blob/e50cabfed1984c341af0d0c056a325a8aec26980/packages/nuxt/src/core/runtime/nitro/renderer.ts#L28), [event](https://github.com/h3js/h3/blob/f6ceb5581043dc4d8b6eab91e9be4531e0c30f8e/src/types.ts#L38), [islandContext](https://github.com/nuxt/nuxt/blob/e50cabfed1984c341af0d0c056a325a8aec26980/packages/nuxt/src/core/runtime/nitro/renderer.ts#L38)
101
101
  `close` | - | Called when Nitro is closed. | -
102
- `error` | `error, { event? }` | Called when an error occurs. | [error](https://github.com/nitrojs/nitro/blob/d20ffcbd16fc4003b774445e1a01e698c2bb078a/src/types/runtime/nitro.ts#L48), [event](https://github.com/unjs/h3/blob/f6ceb5581043dc4d8b6eab91e9be4531e0c30f8e/src/types.ts#L38)
103
- `request` | `event` | Called when a request is received. | [event](https://github.com/unjs/h3/blob/f6ceb5581043dc4d8b6eab91e9be4531e0c30f8e/src/types.ts#L38)
104
- `beforeResponse` | `event, { body }` | Called before sending the response. | [event](https://github.com/unjs/h3/blob/f6ceb5581043dc4d8b6eab91e9be4531e0c30f8e/src/types.ts#L38), unknown
105
- `afterResponse` | `event, { body }` | Called after sending the response. | [event](https://github.com/unjs/h3/blob/f6ceb5581043dc4d8b6eab91e9be4531e0c30f8e/src/types.ts#L38), unknown
102
+ `error` | `error, { event? }` | Called when an error occurs. | [error](https://github.com/nitrojs/nitro/blob/d20ffcbd16fc4003b774445e1a01e698c2bb078a/src/types/runtime/nitro.ts#L48), [event](https://github.com/h3js/h3/blob/f6ceb5581043dc4d8b6eab91e9be4531e0c30f8e/src/types.ts#L38)
103
+ `request` | `event` | Called when a request is received. | [event](https://github.com/h3js/h3/blob/f6ceb5581043dc4d8b6eab91e9be4531e0c30f8e/src/types.ts#L38)
104
+ `beforeResponse` | `event, { body }` | Called before sending the response. | [event](https://github.com/h3js/h3/blob/f6ceb5581043dc4d8b6eab91e9be4531e0c30f8e/src/types.ts#L38), unknown
105
+ `afterResponse` | `event, { body }` | Called after sending the response. | [event](https://github.com/h3js/h3/blob/f6ceb5581043dc4d8b6eab91e9be4531e0c30f8e/src/types.ts#L38), unknown
@@ -52,7 +52,7 @@ Note that `fix:` and `feat:` are for **actual code changes** (that might affect
52
52
 
53
53
  * ~~`fix: typo`~~ -> `docs: fix typo`
54
54
 
55
- If you are working in a project with a monorepo, like `nuxt/nuxt`, ensure that you specify the main scope of your commit in brackets. For example: `feat(nuxi): add 'do-magic' command`.
55
+ If you are working in a project with a monorepo, like `nuxt/nuxt`, ensure that you specify the main scope of your commit in brackets. For example: `feat(kit): add 'addMagicStuff' utility`.
56
56
 
57
57
  #### Making the Pull Request
58
58
 
@@ -30,8 +30,8 @@ Check [Discussions](https://github.com/nuxt/nuxt/discussions) and [RFCs](https:/
30
30
 
31
31
  Milestone | Expected date | Notes | Description
32
32
  -------------|---------------|------------------------------------------------------------------------|-----------------------
33
- SEO & PWA | 2024 | [nuxt/nuxt#18395](https://github.com/nuxt/nuxt/discussions/18395) | Migrating from [nuxt-community/pwa-module](https://github.com/nuxt-community/pwa-module) for built-in SEO utils and service worker support
34
- Assets | 2024 | [nuxt/nuxt#22012](https://github.com/nuxt/nuxt/discussions/22012) | Allow developers and modules to handle loading third-party assets.
33
+ SEO & PWA | 2025 | [nuxt/nuxt#18395](https://github.com/nuxt/nuxt/discussions/18395) | Migrating from [nuxt-community/pwa-module](https://github.com/nuxt-community/pwa-module) for built-in SEO utils and service worker support
34
+ Assets | 2025 | [nuxt/nuxt#22012](https://github.com/nuxt/nuxt/discussions/22012) | Allow developers and modules to handle loading third-party assets.
35
35
  Translations | - | [nuxt/translations#4](https://github.com/nuxt/translations/discussions/4) ([request access](https://github.com/nuxt/nuxt/discussions/16054)) | A collaborative project for a stable translation process for Nuxt docs. Currently pending for ideas and documentation tooling support (content v2 with remote sources).
36
36
 
37
37
  ## Core Modules Roadmap
@@ -40,33 +40,38 @@ In addition to the Nuxt framework, there are modules that are vital for the ecos
40
40
 
41
41
  Module | Status | Nuxt Support | Repository | Description
42
42
  ------------------------------------|---------------------|--------------|------------|-------------------
43
- [Scripts](https://scripts.nuxt.com) | Public Beta | 3.x | [nuxt/scripts](https://github.com/nuxt/scripts) | Easy 3rd party script management.
44
- Auth Utils | Planned | 3.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 | 3.x | `nuxt/a11y` to be announced | Accessibility hinting and utilities [nuxt/nuxt#23255](https://github.com/nuxt/nuxt/issues/23255)
46
- Hints | Planned | 3.x | `nuxt/hints` to be announced | Guidance and suggestions for enhancing development practices.
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 | Planned | 4.x, 5.x | `nuxt/hints` to be announced | Guidance and suggestions for enhancing development practices.
47
47
 
48
48
  ## Release Cycle
49
49
 
50
50
  Since January 2023, we've adopted a consistent release cycle for Nuxt, following [semver](https://semver.org). We aim for major framework releases every year, with an expectation of patch releases every week or so and minor releases every month or so. They should never contain breaking changes except within options clearly marked as `experimental`.
51
51
 
52
+ We are planning a slight variation from this plan for Nuxt 4 and Nuxt 5. Nuxt 4 will be a stability-focused release containing all `compatibilityVersion: 4` features, and will be followed shortly by Nuxt 5 which will include an upgrade to Nitro v3 and additional changes.
53
+
54
+ This approach separates breaking changes into manageable phases, allowing for better ecosystem testing and smoother migrations.
55
+
52
56
  ### Ongoing Support for Nuxt
53
57
 
54
- Going forward from v3, we commit to support each major version of Nuxt for a minimum of a year after the last release, and to providing an upgrade path for current users at that point.
58
+ We commit to support each major version of Nuxt for a minimum of six months after the release of the next major version, and to providing an upgrade path for current users at that point.
55
59
 
56
60
  ### Current Packages
57
61
 
58
62
  The current active version of [Nuxt](https://nuxt.com) is **v3** which is available as `nuxt` on npm with the `latest` tag.
59
63
 
60
- Nuxt 2 is in maintenance mode and is available on npm with the `2x` tag. It will reach End of Life (EOL) on June 30, 2024.
64
+ Nuxt 2 is in maintenance mode and is available on npm with the `2x` tag. It reached End of Life (EOL) on June 30, 2024.
61
65
 
62
66
  Each active version has its own nightly releases which are generated automatically. For more about enabling the Nuxt nightly release channel, see [the nightly release channel docs](/docs/guide/going-further/nightly-release-channel).
63
67
 
64
68
  Release | | Initial release | End Of Life | Docs
65
69
  ----------------------------------------|---------------------------------------------------------------------------------------------------|-----------------|--------------|-------
66
- **4.x** (scheduled) | | approximately 1 month after release of nitro v3 | | &nbsp;
67
- **3.x** (stable) | <a href="https://npmjs.com/package/nuxt"><img alt="Nuxt latest 3.x version" src="https://flat.badgen.net/npm/v/nuxt?label=" class="not-prose"></a> | 2022-11-16 | TBA | [nuxt.com](/docs)
68
- **2.x** (unsupported) | <a href="https://www.npmjs.com/package/nuxt?activeTab=versions"><img alt="Nuxt 2.x version" src="https://flat.badgen.net/npm/v/nuxt/2x?label=" class="not-prose"></a> | 2018-09-21 | 2024-06-30 | [v2.nuxt.com](https://v2.nuxt.com/docs)
69
- **1.x** (unsupported) | <a href="https://www.npmjs.com/package/nuxt?activeTab=versions"><img alt="Nuxt 1.x version" src="https://flat.badgen.net/npm/v/nuxt/1x?label=" class="not-prose"></a> | 2018-01-08 | 2019-09-21 | &nbsp;
70
+ **5.x** (scheduled) | | Q4 2025 (estimated) | TBA | &nbsp;
71
+ **4.x** (scheduled) | | 2025-06-30 (planned) | 6 months after 5.x release | &nbsp;
72
+ **3.x** (stable) | <a href="https://npmjs.com/package/nuxt"><img alt="Nuxt latest 3.x version" src="https://flat.badgen.net/npm/v/nuxt?label=" class="not-prose"></a> | 2022-11-16 | 2025-12-31 (TBC) | [nuxt.com](/docs)
73
+ **2.x** (unsupported) | <a href="https://www.npmjs.com/package/nuxt?activeTab=versions"><img alt="Nuxt 2.x version" src="https://flat.badgen.net/npm/v/nuxt/2x?label=" class="not-prose"></a> | 2018-09-21 | 2024-06-30 | [v2.nuxt.com](https://v2.nuxt.com/docs)
74
+ **1.x** (unsupported) | <a href="https://www.npmjs.com/package/nuxt?activeTab=versions"><img alt="Nuxt 1.x version" src="https://flat.badgen.net/npm/v/nuxt/1x?label=" class="not-prose"></a> | 2018-01-08 | 2019-09-21 | &nbsp;
70
75
 
71
76
  ### Support Status
72
77