---
title: Command Line Interface
linkText: CLI
---

The command line interface (CLI) can be used if no adapter is available for your framework or if you want to use the adapter in a different way. The CLI is a Node.js application that can be run parallel to your dev server and before your production build.

## Installation

<div className="steps">
<div className="step">

First, install the required packages:

We have to install the following packages:

- `@content-collections/core`
- `@content-collections/next`
- `concurrently`

```package-install
npm i @content-collections/core @content-collections/cli concurrently -D
```

</div>
<div className="step">

After installation we have to add a path alias for the generated collections to the `tsconfig.json`:

```json
{
  "compilerOptions": {
    // ...
    "paths": {
      "content-collections": ["./.content-collections/generated"]
    }
  }
}
```

</div>
<div className="step">

Add the content-collection cli to your package.json scripts:

```json
{
  "scripts": {
    "dev": "concurrently \"content-collections watch\" \"build-scripts dev\"",
    "build": "content-collections build && build-scripts build"
  }
}
```

First, we modify the dev script to simultaneously execute the content-collections watch command along with our regular dev command.

Next, we execute the content-collections build command prior to our regular build command.

<Callout type="info">
  The `build-scripts` command is a placeholder for your actual build command.
  Replace it with the command you use to build your project.
</Callout>

</div>
</div>

## Commands

The CLI provides the following commands:

### Watch

`content-collections watch` watches the configured paths for changes and updates the collections accordingly. This command is useful during development to keep the collections up to date. It is recommended to run this command in parallel to your dev server.

| Flag              | Description                                                           |
| ----------------- | --------------------------------------------------------------------- |
| `--config <path>` | Path to the configuration file. Defaults to `content-collections.ts`. |

### Build

`content-collections build` builds the collections and writes them to the file system. This command is useful for production builds.

| Flag              | Description                                                           |
| ----------------- | --------------------------------------------------------------------- |
| `--config <path>` | Path to the configuration file. Defaults to `content-collections.ts`. |
