---
title: stx connect
description: Connect a local docs directory to an existing Syntext project.
icon: link
---

# stx connect

Link your local documentation to a Syntext project by writing the `projectId` into your config file. Use this when you created a project in the dashboard (or with `stx projects create`) and want your local docs to deploy to it.

## Usage

```bash
stx connect <projectId> [options]
```

## Arguments

| Argument | Description |
|----------|-------------|
| `<projectId>` | Project ID to connect to — find it with `stx projects list` |

## Options

| Flag | Alias | Type | Default | Description |
|------|-------|------|---------|-------------|
| `--dir <dir>` | `-d` | string | `.` | Documentation directory |
| `--json` | | boolean | `false` | Output result as JSON |

## What It Does

1. Verifies you have access to the project (requires `stx login` first)
2. Locates your config file (`syntext.json`, `syntext.yaml`, `stx.json`, or `stx.yaml`)
3. Writes the `projectId` field into it

```
✔ Connected to Acme Docs

  Project:  Acme Docs
  ID:       prj_abc123
  Docs URL: https://acme-docs.syntext.dev
  Config:   syntext.json

  You can now run:
    stx dev      — watch & deploy previews
    stx deploy   — publish to production
```

## Examples

### Connect the Current Directory

```bash
stx projects list          # find your project ID
stx connect prj_abc123
```

### Connect a Nested Docs Directory

```bash
stx connect prj_abc123 --dir ./docs-site
```

### Scripted (JSON Output)

```bash
stx connect prj_abc123 --json
```

```json
{ "success": true, "projectId": "prj_abc123", "name": "Acme Docs", "docsUrl": "https://acme-docs.syntext.dev" }
```

## Troubleshooting

| Error | Fix |
|-------|-----|
| `Not authenticated` | Run `stx login` first |
| `Project not found` | Check the ID with `stx projects list` |
| `No access to project` | Ask an org admin to invite you to the project |
| `No config file found` | Run `stx init` to scaffold the project structure first |

## Related

- [stx projects](/cli/projects) — create and list projects
- [stx init](/cli/init) — scaffold a new docs project
- [stx deploy](/cli/deploy) — publish to production
