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

# Deployment

> Deploy your LinkApp to Linktree

## Prerequisites

Before deploying, make sure you have:

1. A valid `linkapp.config.ts` with required `manifest` fields
2. A production build in `dist/` (or linkapp will build automatically)
3. Authentication credentials (run `npx @linktr.ee/linkapp login` first)

## Authenticate

Log in to Linktree before your first deployment:

<CodeGroup>
  ```bash Production theme={"system"}
  npx @linktr.ee/linkapp login
  ```

  ```bash QA theme={"system"}
  npx @linktr.ee/linkapp login --qa
  ```
</CodeGroup>

This opens a browser window for OAuth device flow authentication. Your tokens are stored in `~/.config/linkapp/auth-token.json`.

## Deploy your LinkApp

Deploy to production:

<CodeGroup>
  ```bash npm theme={"system"}
  npm run deploy
  ```

  ```bash pnpm theme={"system"}
  pnpm deploy
  ```

  ```bash yarn theme={"system"}
  yarn deploy
  ```

  ```bash bun theme={"system"}
  bun deploy
  ```
</CodeGroup>

Or use the CLI directly:

```bash theme={"system"}
npx @linktr.ee/linkapp deploy
```

### Deploy to QA

To deploy to the QA environment:

```bash theme={"system"}
npx @linktr.ee/linkapp deploy --qa
```

## Deployment process

When you run `linkapp deploy`:

1. **Validates** your project and config
2. **Builds** the app (if needed)
3. **Uploads** to Linktree

## Deployment flags

| Flag            | Description                                    |
| --------------- | ---------------------------------------------- |
| `--qa`          | Deploy to QA environment instead of production |
| `--skip-build`  | Skip building (use existing `dist/`)           |
| `--skip-checks` | Skip pre-deployment validation                 |
| `--force`       | Force deploy even if warnings                  |

Example:

```bash theme={"system"}
npx @linktr.ee/linkapp deploy --qa --skip-build
```

## After deployment

After a successful deployment, you'll see:

```
✓ Deployed successfully!

Build URL: https://linktr.ee/builds/abc123
Test link: https://linktr.ee/test?app=my-app

Next steps:
  • View your build in the Linktree dashboard
  • Test your LinkApp on a Linktree profile
  • Share the build URL with your team
```

<Tip>
  Use the test link to preview your LinkApp on a real Linktree profile before
  publishing.
</Tip>

## Troubleshooting

### Validation errors

If you see config validation errors:

```
Error: Invalid config
  - manifest.title: Required
  - manifest.description: Max 200 characters
  - settings[0].id: Must be alphanumeric
```

Fix these in your `linkapp.config.ts` and redeploy.

### Bundle size warnings

If your bundle exceeds 5MB:

```
⚠ Warning: Bundle size is 6.2MB (exceeds 5MB recommended limit)
```

Consider using dynamic imports, removing unused dependencies, or optimizing images.

### Authentication errors

If you see `401 Unauthorized`:

```bash theme={"system"}
npx @linktr.ee/linkapp logout
npx @linktr.ee/linkapp login
```

### Build errors

If the build fails during deployment:

```bash theme={"system"}
# Build locally to see errors
npx @linktr.ee/linkapp build

# Fix errors, then deploy
npx @linktr.ee/linkapp deploy --skip-build
```

### Config schema errors

Check your config against the schema:

```bash theme={"system"}
# This will validate during build
npx @linktr.ee/linkapp build
```

### Deployment fails

Enable verbose logging:

```bash theme={"system"}
DEBUG=linkapp:* npx @linktr.ee/linkapp deploy
```

## Multiple environments

You can maintain separate LinkApps for development and production:

```ts linkapp.config.ts theme={"system"}
export default {
  manifest: {
    name: process.env.LINKAPP_ENV === "qa" ? "My App QA" : "My App",
    // Generates IDs: "my-app-qa" or "my-app"
  },
  settings: {
    title: process.env.LINKAPP_ENV === "qa" ? "My App (QA)" : "My App",
  },
};
```

Deploy to QA:

```bash theme={"system"}
LINKAPP_ENV=qa npx @linktr.ee/linkapp deploy --qa
```

Deploy to production:

```bash theme={"system"}
LINKAPP_ENV=prod npx @linktr.ee/linkapp deploy
```

## CI/CD integration

Deploy from CI/CD pipelines:

```yaml .github/workflows/deploy.yml theme={"system"}
name: Deploy LinkApp

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 18
      - run: npm install
      - run: npm run build
      - run: npm run deploy
        env:
          LINKTREE_TOKEN: ${{ secrets.LINKTREE_TOKEN }}
```

<Warning>
  Store your authentication token as a secret. Never commit `auth-token.json` or
  tokens to version control.
</Warning>

## Next steps

<CardGroup cols={2}>
  <Card title="CLI Reference" icon="terminal" href="/cli/deploy">
    See all deploy command options
  </Card>

  <Card title="Build" icon="hammer" href="/cli/build">
    Learn about the build process
  </Card>
</CardGroup>
