2022-10-06 09:15:30 +00:00
---
title: "nuxi add"
description: "Scaffold an entity into your Nuxt application."
2023-10-18 10:59:43 +00:00
links:
- label: Source
icon: i-simple-icons-github
to: https://github.com/nuxt/cli/blob/main/src/commands/add.ts
size: xs
2022-10-06 09:15:30 +00:00
---
2022-04-06 05:56:08 +00:00
2024-12-18 10:29:56 +00:00
<!-- add - cmd -->
2023-10-18 10:59:43 +00:00
```bash [Terminal]
2024-12-18 10:29:56 +00:00
npx nuxi add < TEMPLATE > < NAME > [--cwd=< directory > ] [--logLevel=< silent | info | verbose > ] [--force]
2022-04-06 05:56:08 +00:00
```
2024-12-18 10:29:56 +00:00
<!-- /add - cmd -->
### Arguments
<!-- add - args -->
Argument | Description
--- | ---
`TEMPLATE` | Specify which template to generate (options: < api \|plugin \|component \|composable \|middleware \|layout \|page > )
`NAME` | Specify name of the generated file
<!-- /add - args -->
### Options
<!-- add - opts -->
Option | Default | Description
--- | --- | ---
`--cwd=<directory>` | `.` | Specify the working directory
`--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
`--force` | `false` | Force override file if it already exists
<!-- /add - opts -->
2022-04-06 05:56:08 +00:00
2022-08-23 20:44:25 +00:00
**Modifiers:**
2022-04-06 05:56:08 +00:00
2022-11-21 10:43:53 +00:00
Some templates support additional modifier flags to add a suffix (like `.client` or `.get` ) to their name.
2022-08-23 20:44:25 +00:00
2023-10-18 10:59:43 +00:00
```bash [Terminal]
# Generates `/plugins/sockets.client.ts`
npx nuxi add plugin sockets --client
```
2022-08-23 20:44:25 +00:00
## `nuxi add component`
* Modifier flags: `--mode client|server` or `--client` or `--server`
2023-10-18 10:59:43 +00:00
```bash [Terminal]
2022-08-23 20:44:25 +00:00
# Generates `components/TheHeader.vue`
2022-04-06 05:56:08 +00:00
npx nuxi add component TheHeader
```
2022-08-23 20:44:25 +00:00
## `nuxi add composable`
2023-10-18 10:59:43 +00:00
```bash [Terminal]
2022-08-23 20:44:25 +00:00
# Generates `composables/foo.ts`
npx nuxi add composable foo
```
2022-04-06 05:56:08 +00:00
2022-08-23 20:44:25 +00:00
## `nuxi add layout`
2023-10-18 10:59:43 +00:00
```bash [Terminal]
2022-08-29 09:35:55 +00:00
# Generates `layouts/custom.vue`
2022-08-23 20:44:25 +00:00
npx nuxi add layout custom
```
## `nuxi add plugin`
* Modifier flags: `--mode client|server` or `--client` or `--server`
2023-10-18 10:59:43 +00:00
```bash [Terminal]
2022-08-23 20:44:25 +00:00
# Generates `plugins/analytics.ts`
npx nuxi add plugin analytics
```
## `nuxi add page`
2023-10-18 10:59:43 +00:00
```bash [Terminal]
2022-08-23 20:44:25 +00:00
# Generates `pages/about.vue`
npx nuxi add page about
```
2023-10-18 10:59:43 +00:00
```bash [Terminal]
2022-08-23 20:44:25 +00:00
# Generates `pages/category/[id].vue`
npx nuxi add page "category/[id]"
```
## `nuxi add middleware`
* Modifier flags: `--global`
2023-10-18 10:59:43 +00:00
```bash [Terminal]
2022-08-23 20:44:25 +00:00
# Generates `middleware/auth.ts`
npx nuxi add middleware auth
```
## `nuxi add api`
2022-11-14 10:11:16 +00:00
* Modifier flags: `--method` (can accept `connect` , `delete` , `get` , `head` , `options` , `patch` , `post` , `put` or `trace` ) or alternatively you can directly use `--get` , `--post` , etc.
2022-08-23 20:44:25 +00:00
2023-10-18 10:59:43 +00:00
```bash [Terminal]
2022-08-23 20:44:25 +00:00
# Generates `server/api/hello.ts`
npx nuxi add api hello
```