---
title: "nuxt task"
description: "List and run Nitro tasks on your dev server."
canonical_url: "https://nuxt.com/docs/4.x/api/commands/task"
---
# nuxt task

> List and run Nitro tasks on your dev server.

The `task` command talks to the [Nitro tasks](https://nitro.build/guide/tasks) your project exposes, using the `nuxt dev` server running for it. Pass `--url` to target another server.

## `nuxt task list`

```bash [Terminal]
npx nuxt task list [ROOTDIR] [--cwd=<directory>] [--url=<url>] [--json]
```

![nuxt task list](https://raw.githubusercontent.com/nuxt/cli/main/capture/output/nuxt-task-list.svg)

### Arguments

<table>
<thead>
  <tr>
    <th>
      Argument
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        ROOTDIR
      </code>
    </td>
    
    <td>
      The root directory of your Nuxt project (default: .)
    </td>
  </tr>
</tbody>
</table>

### Options

<table>
<thead>
  <tr>
    <th>
      Option
    </th>
    
    <th>
      Default
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        --cwd=<directory>
      </code>
    </td>
    
    <td>
      
    </td>
    
    <td>
      Specify the root directory of your Nuxt project
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --url=<url>
      </code>
    </td>
    
    <td>
      
    </td>
    
    <td>
      URL of the Nuxt server to talk to (default: the running dev server)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --json
      </code>
    </td>
    
    <td>
      
    </td>
    
    <td>
      Print output as JSON
    </td>
  </tr>
</tbody>
</table>

## `nuxt task run`

```bash [Terminal]
npx nuxt task run <NAME> [ROOTDIR] [--cwd=<directory>] [--url=<url>] [--payload=<json>]
```

### Arguments

<table>
<thead>
  <tr>
    <th>
      Argument
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        NAME=<name>
      </code>
    </td>
    
    <td>
      Name of the task to run
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ROOTDIR
      </code>
    </td>
    
    <td>
      The root directory of your Nuxt project (default: .)
    </td>
  </tr>
</tbody>
</table>

### Options

<table>
<thead>
  <tr>
    <th>
      Option
    </th>
    
    <th>
      Default
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        --cwd=<directory>
      </code>
    </td>
    
    <td>
      
    </td>
    
    <td>
      Specify the root directory of your Nuxt project
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --url=<url>
      </code>
    </td>
    
    <td>
      
    </td>
    
    <td>
      URL of the Nuxt server to talk to (default: the running dev server)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --payload=<json>
      </code>
    </td>
    
    <td>
      
    </td>
    
    <td>
      Task payload, either as a JSON object or as <code>
        --payload.key=value
      </code>
      
       pairs
    </td>
  </tr>
</tbody>
</table>

The task's result is printed as JSON. A payload can be given as a single JSON object or built up from individual keys:

```bash [Terminal]
npx nuxt task run db:seed --payload '{"count":10}'
npx nuxt task run db:seed --payload.count=10
```

::note
Nitro only scans your `tasks` directory when tasks are enabled, so a server with none exposed may just need this:

```ts [nuxt.config.ts]
export default defineNuxtConfig({
  nitro: {
    experimental: {
      tasks: true,
    },
  },
})
```
::

::read-more{icon="i-simple-icons-nitro" target="\_blank" to="https://nitro.build/guide/tasks"}
Read more about Nitro tasks.
::

---

- [Source](https://github.com/nuxt/cli/tree/main/packages/nuxt-cli/src/commands/task)


## Sitemap

See the full [sitemap](https://nuxt.com/sitemap.md) for all pages.
