Skip to content

Commit 44a071e

Browse files
authored
docs: move cli documentation into repository (#1465)
1 parent 4186332 commit 44a071e

17 files changed

Lines changed: 800 additions & 0 deletions

docs/.navigation.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
title: Commands
2+
titleTemplate: '%s · Nuxt Commands'
3+
icon: i-lucide-square-terminal

docs/add.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
---
2+
title: "nuxt add"
3+
description: "Scaffold an entity into your Nuxt application."
4+
links:
5+
- label: Source
6+
icon: i-simple-icons-github
7+
to: https://github.com/nuxt/cli/blob/main/packages/nuxi/src/commands/add-template.ts
8+
size: xs
9+
---
10+
11+
<!--add-cmd-->
12+
```bash [Terminal]
13+
npx nuxt add <TEMPLATE> <NAME> [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--force]
14+
```
15+
<!--/add-cmd-->
16+
17+
## Arguments
18+
19+
<!--add-args-->
20+
| Argument | Description |
21+
|------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
22+
| `TEMPLATE` | Specify which template to generate (options: <api\|app\|app-config\|component\|composable\|error\|layer\|layout\|middleware\|module\|page\|plugin\|server-middleware\|server-plugin\|server-route\|server-util>) |
23+
| `NAME` | Specify name of the generated file |
24+
<!--/add-args-->
25+
26+
## Options
27+
28+
<!--add-opts-->
29+
| Option | Default | Description |
30+
|--------------------------------------|---------|------------------------------------------|
31+
| `--cwd=<directory>` | `.` | Specify the working directory |
32+
| `--logLevel=<silent\|info\|verbose>` | | Specify build-time log level |
33+
| `--force` | `false` | Force override file if it already exists |
34+
<!--/add-opts-->
35+
36+
**Modifiers:**
37+
38+
Some templates support additional modifier flags to add a suffix (like `.client` or `.get`) to their name.
39+
40+
```bash [Terminal]
41+
# Generates `/plugins/sockets.client.ts`
42+
npx nuxt add plugin sockets --client
43+
```
44+
45+
## `nuxt add component`
46+
47+
* Modifier flags: `--mode client|server` or `--client` or `--server`
48+
49+
```bash [Terminal]
50+
# Generates `app/components/TheHeader.vue`
51+
npx nuxt add component TheHeader
52+
```
53+
54+
## `nuxt add composable`
55+
56+
```bash [Terminal]
57+
# Generates `app/composables/foo.ts`
58+
npx nuxt add composable foo
59+
```
60+
61+
## `nuxt add layout`
62+
63+
```bash [Terminal]
64+
# Generates `app/layouts/custom.vue`
65+
npx nuxt add layout custom
66+
```
67+
68+
## `nuxt add plugin`
69+
70+
* Modifier flags: `--mode client|server` or `--client`or `--server`
71+
72+
```bash [Terminal]
73+
# Generates `app/plugins/analytics.ts`
74+
npx nuxt add plugin analytics
75+
```
76+
77+
## `nuxt add page`
78+
79+
```bash [Terminal]
80+
# Generates `app/pages/about.vue`
81+
npx nuxt add page about
82+
```
83+
84+
```bash [Terminal]
85+
# Generates `app/pages/category/[id].vue`
86+
npx nuxt add page "category/[id]"
87+
```
88+
89+
## `nuxt add middleware`
90+
91+
* Modifier flags: `--global`
92+
93+
```bash [Terminal]
94+
# Generates `app/middleware/auth.ts`
95+
npx nuxt add middleware auth
96+
```
97+
98+
## `nuxt add api`
99+
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+
102+
```bash [Terminal]
103+
# Generates `server/api/hello.ts`
104+
npx nuxt add api hello
105+
```
106+
107+
## `nuxt add layer`
108+
109+
```bash [Terminal]
110+
# Generates `layers/subscribe/nuxt.config.ts`
111+
npx nuxt add layer subscribe
112+
```

docs/analyze.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: "nuxt analyze"
3+
description: "Analyze the production bundle or your Nuxt application."
4+
links:
5+
- label: Source
6+
icon: i-simple-icons-github
7+
to: https://github.com/nuxt/cli/blob/main/packages/nuxi/src/commands/analyze.ts
8+
size: xs
9+
---
10+
11+
<!--analyze-cmd-->
12+
```bash [Terminal]
13+
npx nuxt analyze [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--dotenv] [-e, --extends=<layer-name>] [--name=<name>] [--no-serve]
14+
```
15+
<!--/analyze-cmd-->
16+
17+
The `analyze` command builds Nuxt and analyzes the production bundle (experimental).
18+
19+
## Arguments
20+
21+
<!--analyze-args-->
22+
| Argument | Description |
23+
|---------------|------------------------------------------------|
24+
| `ROOTDIR="."` | Specifies the working directory (default: `.`) |
25+
<!--/analyze-args-->
26+
27+
## Options
28+
29+
<!--analyze-opts-->
30+
| Option | Default | Description |
31+
|--------------------------------------|-----------|----------------------------------------------------------------------------------|
32+
| `--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`) |
33+
| `--logLevel=<silent\|info\|verbose>` | | Specify build-time log level |
34+
| `--dotenv` | | Path to `.env` file to load, relative to the root directory |
35+
| `-e, --extends=<layer-name>` | | Extend from a Nuxt layer |
36+
| `--name=<name>` | `default` | Name of the analysis |
37+
| `--no-serve` | | Skip serving the analysis results |
38+
<!--/analyze-opts-->
39+
40+
::note
41+
This command sets `process.env.NODE_ENV` to `production`.
42+
::

docs/build-module.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: 'nuxt build-module'
3+
description: 'Nuxt command to build your Nuxt module before publishing.'
4+
links:
5+
- label: Source
6+
icon: i-simple-icons-github
7+
to: https://github.com/nuxt/module-builder/blob/main/src/cli.ts
8+
size: xs
9+
---
10+
11+
<!--build-module-cmd-->
12+
```bash [Terminal]
13+
npx nuxt build-module [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--build] [--stub] [--sourcemap] [--prepare]
14+
```
15+
<!--/build-module-cmd-->
16+
17+
The `build-module` command runs `@nuxt/module-builder` to generate `dist` directory within your `rootDir` that contains the full build for your **nuxt-module**.
18+
19+
## Arguments
20+
21+
<!--build-module-args-->
22+
| Argument | Description |
23+
|---------------|------------------------------------------------|
24+
| `ROOTDIR="."` | Specifies the working directory (default: `.`) |
25+
<!--/build-module-args-->
26+
27+
## Options
28+
29+
<!--build-module-opts-->
30+
| Option | Default | Description |
31+
|--------------------------------------|---------|----------------------------------------------------------------------------------|
32+
| `--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`) |
33+
| `--logLevel=<silent\|info\|verbose>` | | Specify build-time log level |
34+
| `--build` | `false` | Build module for distribution |
35+
| `--stub` | `false` | Stub dist instead of actually building it for development |
36+
| `--sourcemap` | `false` | Generate sourcemaps |
37+
| `--prepare` | `false` | Prepare module for local development |
38+
<!--/build-module-opts-->
39+
40+
::read-more{to="https://github.com/nuxt/module-builder" icon="i-simple-icons-github" target="\_blank"}
41+
Read more about `@nuxt/module-builder`.
42+
::

docs/build.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
title: "nuxt build"
3+
description: "Build your Nuxt application."
4+
links:
5+
- label: Source
6+
icon: i-simple-icons-github
7+
to: https://github.com/nuxt/cli/blob/main/packages/nuxi/src/commands/build.ts
8+
size: xs
9+
---
10+
11+
<!--build-cmd-->
12+
```bash [Terminal]
13+
npx nuxt build [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--prerender] [--preset] [--dotenv] [--envName] [-e, --extends=<layer-name>] [--profile[=verbose]]
14+
```
15+
<!--/build-cmd-->
16+
17+
The `build` command creates a `.output` directory with all your application, server and dependencies ready for production.
18+
19+
## Arguments
20+
21+
<!--build-args-->
22+
| Argument | Description |
23+
|---------------|------------------------------------------------|
24+
| `ROOTDIR="."` | Specifies the working directory (default: `.`) |
25+
<!--/build-args-->
26+
27+
## Options
28+
29+
<!--build-opts-->
30+
| Option | Default | Description |
31+
|--------------------------------------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------|
32+
| `--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`) |
33+
| `--logLevel=<silent\|info\|verbose>` | | Specify build-time log level |
34+
| `--prerender` | | Build Nuxt and prerender static routes |
35+
| `--preset=<preset>` | | Specify Nitro server preset. Available presets depend on Nitro (e.g. `node-server`, `vercel`, `netlify`, `static`) |
36+
| `--dotenv` | | Path to `.env` file to load, relative to the root directory |
37+
| `--envName` | | The environment to use when resolving configuration overrides (default is `production` when building, and `development` when running the dev server) |
38+
| `-e, --extends=<layer-name>` | | Extend from a Nuxt layer |
39+
| `--profile` :badge[v4.4]{color="info" size="xs" class="align-middle"} | | Profile performance. Writes a V8 CPU profile and JSON report on exit. Use `--profile=verbose` for a full console report. |
40+
<!--/build-opts-->
41+
42+
::note
43+
This command sets `process.env.NODE_ENV` to `production`.
44+
::
45+
46+
::note
47+
`--prerender` will always set the `preset` to `static`
48+
::

docs/cleanup.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: 'nuxt cleanup'
3+
description: 'Remove common generated Nuxt files and caches.'
4+
links:
5+
- label: Source
6+
icon: i-simple-icons-github
7+
to: https://github.com/nuxt/cli/blob/main/packages/nuxi/src/commands/cleanup.ts
8+
size: xs
9+
---
10+
11+
<!--cleanup-cmd-->
12+
```bash [Terminal]
13+
npx nuxt cleanup [ROOTDIR] [--cwd=<directory>]
14+
```
15+
<!--/cleanup-cmd-->
16+
17+
The `cleanup` command removes common generated Nuxt files and caches, including:
18+
19+
- `.nuxt`
20+
- `.output`
21+
- `node_modules/.vite`
22+
- `node_modules/.cache`
23+
24+
## Arguments
25+
26+
<!--cleanup-args-->
27+
| Argument | Description |
28+
|---------------|------------------------------------------------|
29+
| `ROOTDIR="."` | Specifies the working directory (default: `.`) |
30+
<!--/cleanup-args-->
31+
32+
## Options
33+
34+
<!--cleanup-opts-->
35+
| Option | Default | Description |
36+
|---------------------|---------|----------------------------------------------------------------------------------|
37+
| `--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`) |
38+
<!--/cleanup-opts-->

docs/dev.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
title: 'nuxt dev'
3+
description: The dev command starts a development server with hot module replacement at http://localhost:3000
4+
links:
5+
- label: Source
6+
icon: i-simple-icons-github
7+
to: https://github.com/nuxt/cli/blob/main/packages/nuxi/src/commands/dev.ts
8+
size: xs
9+
---
10+
11+
<!--dev-cmd-->
12+
```bash [Terminal]
13+
npx nuxt dev [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--dotenv] [--envName] [-e, --extends=<layer-name>] [--clear] [--no-f, --no-fork] [-p, --port] [-h, --host] [--clipboard] [-o, --open] [--https] [--publicURL] [--qr] [--public] [--tunnel] [--profile[=verbose]] [--sslCert] [--sslKey]
14+
```
15+
<!--/dev-cmd-->
16+
17+
The `dev` command starts a development server with hot module replacement at [http://localhost:3000](https://localhost:3000)
18+
19+
## Arguments
20+
21+
<!--dev-args-->
22+
| Argument | Description |
23+
|---------------|------------------------------------------------|
24+
| `ROOTDIR="."` | Specifies the working directory (default: `.`) |
25+
<!--/dev-args-->
26+
27+
## Options
28+
29+
<!--dev-opts-->
30+
| Option | Default | Description |
31+
|--------------------------------------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------|
32+
| `--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`) |
33+
| `--logLevel=<silent\|info\|verbose>` | | Specify build-time log level |
34+
| `--dotenv` | | Path to `.env` file to load, relative to the root directory |
35+
| `--envName` | | The environment to use when resolving configuration overrides (default is `production` when building, and `development` when running the dev server) |
36+
| `-e, --extends=<layer-name>` | | Extend from a Nuxt layer |
37+
| `--clear` | `false` | Clear console on restart |
38+
| `--no-f, --no-fork` | | Disable forked mode |
39+
| `-p, --port` | | Port to listen on (default: `NUXT_PORT \|\| NITRO_PORT \|\| PORT \|\| nuxtOptions.devServer.port`) |
40+
| `-h, --host` | | Host to listen on (default: `NUXT_HOST \|\| NITRO_HOST \|\| HOST \|\| nuxtOptions.devServer?.host`) |
41+
| `--clipboard` | `false` | Copy the URL to the clipboard |
42+
| `-o, --open` | `false` | Open the URL in the browser |
43+
| `--https` | | Enable HTTPS |
44+
| `--publicURL` | | Displayed public URL (used for QR code) |
45+
| `--qr` | | Display The QR code of public URL when available |
46+
| `--public` | | Listen to all network interfaces |
47+
| `--tunnel` | | Open a tunnel using https://github.com/unjs/untun |
48+
| `--profile` :badge[v4.4]{color="info" size="xs" class="align-middle"} | | Profile performance. Writes a V8 CPU profile and JSON report on exit. Use `--profile=verbose` for a full console report. |
49+
| `--sslCert` | | (DEPRECATED) Use `--https.cert` instead. |
50+
| `--sslKey` | | (DEPRECATED) Use `--https.key` instead. |
51+
<!--/dev-opts-->
52+
53+
The port and host can also be set via NUXT_PORT, PORT, NUXT_HOST or HOST environment variables.
54+
55+
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.
56+
57+
This command sets `process.env.NODE_ENV` to `development`.
58+
59+
::note
60+
If you are using a self-signed certificate in development, you will need to set `NODE_TLS_REJECT_UNAUTHORIZED=0` in your environment.
61+
::

docs/devtools.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: "nuxt devtools"
3+
description: The devtools command allows you to enable or disable Nuxt DevTools on a per-project basis.
4+
links:
5+
- label: Source
6+
icon: i-simple-icons-github
7+
to: https://github.com/nuxt/cli/blob/main/packages/nuxi/src/commands/devtools.ts
8+
size: xs
9+
---
10+
11+
<!--devtools-cmd-->
12+
```bash [Terminal]
13+
npx nuxt devtools <COMMAND> [ROOTDIR] [--cwd=<directory>]
14+
```
15+
<!--/devtools-cmd-->
16+
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+
19+
## Arguments
20+
21+
<!--devtools-args-->
22+
| Argument | Description |
23+
|---------------|------------------------------------------------|
24+
| `COMMAND` | Command to run (options: <enable\|disable>) |
25+
| `ROOTDIR="."` | Specifies the working directory (default: `.`) |
26+
<!--/devtools-args-->
27+
28+
## Options
29+
30+
<!--devtools-opts-->
31+
| Option | Default | Description |
32+
|---------------------|---------|----------------------------------------------------------------------------------|
33+
| `--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`) |
34+
<!--/devtools-opts-->
35+
36+
::read-more{icon="i-simple-icons-nuxtdotjs" to="https://devtools.nuxt.com" target="\_blank"}
37+
Read more about the **Nuxt DevTools**.
38+
::

0 commit comments

Comments
 (0)