> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mixpeek.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI

> Deploy, stream logs, manage previews, and run a local dev server from the command line with @mixpeek/cli.

## Overview

The Mixpeek CLI (`@mixpeek/cli`) lets you deploy Canvas apps, stream build logs, list preview environments, and run a local dev server — all from your terminal.

***

## Installation

```bash theme={null}
npm install -g @mixpeek/cli
```

***

## Authentication

```bash theme={null}
mixpeek login
```

This stores your API key locally for use in subsequent commands. You can also pass `--api-key` to any command.

***

## Commands

### `mixpeek apps deploy`

Build your app locally and deploy it to Canvas.

```bash theme={null}
cd my-app
mixpeek apps deploy --app-id $APP_ID
```

What it does:

1. Detects your package manager (npm, yarn, pnpm)
2. Runs `npm run build` (or equivalent)
3. Zips the `dist/` output directory
4. Uploads the bundle to Mixpeek
5. Triggers a deploy

Options:

| Flag            | Description                    | Default              |
| --------------- | ------------------------------ | -------------------- |
| `--app-id`      | App ID to deploy to            | Required             |
| `--environment` | Target environment             | `production`         |
| `--message`     | Commit message for the version | Auto-generated       |
| `--api-key`     | API key (overrides stored key) | From `mixpeek login` |

<Note>
  The CLI builds `dist/` (not `src/`). Make sure your `build` script outputs to `dist/`, `build/`, or `out/`.
</Note>

***

### `mixpeek apps logs`

Stream real-time build logs for an active deploy.

```bash theme={null}
mixpeek apps logs --app-id $APP_ID --deploy-id $DEPLOY_ID
```

Log lines are printed with timestamps and colored output. The stream closes automatically when the deploy completes or fails.

***

### `mixpeek apps preview`

List active preview deployments for an app.

```bash theme={null}
mixpeek apps preview --app-id $APP_ID
```

Output:

```
Preview Environments:
  preview-42  →  https://pr-42-my-app.mxp.co
  preview-17  →  https://pr-17-my-app.mxp.co
```

***

### `mixpeek apps dev`

Start a local development server with Mixpeek environment variables pre-configured.

```bash theme={null}
mixpeek apps dev --app-id $APP_ID
```

This spawns your project's dev server (e.g., `npm run dev`) with `VITE_MIXPEEK_API_URL` set, so API proxy calls work locally.

***

## CI/CD integration

Use the CLI in GitHub Actions or any CI pipeline:

```yaml theme={null}
# .github/workflows/deploy.yml
name: Deploy to Canvas
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm ci
      - run: npm install -g @mixpeek/cli
      - run: mixpeek apps deploy --app-id ${{ secrets.APP_ID }} --api-key ${{ secrets.MIXPEEK_API_KEY }} --message "Deploy from CI (${{ github.sha }})"
```

***

## Related

* [Deploy from Code](/canvas/apps/deploy)
* [Build Logs](/canvas/apps/build-logs)
* [Preview Deploys](/canvas/apps/preview-deploys)
