---
sidebar_position: 5
title: Push & Pull
description: Deploy components to the Myop platform with myop push and download them with myop pull. Supports single-file and multi-file components, batch operations with myop list, and organization management.
keywords: [myop push, myop pull, myop deploy, myop upload, myop download, myop list, deploy myop component, myop batch operations]
---
# Push & Pull

## Push — Deploy a Component

`myop push` uploads the component to the Myop platform. After a successful push, the component is live immediately — no rebuild or redeploy of the host application needed.

```bash
# Push using componentId from myop.config.json
npx myop push

# Push to a specific component ID (overrides config)
npx myop push <componentId>
```

### What happens during push

1. Reads `myop.config.json` to identify the component
2. If a `componentId` argument is passed, it overrides the config
3. Detects the entry point:
   - **Single-file mode** — `index.html` in the root
   - **Multi-file mode** — `dist/index.html` (runs `npm run build` first)
4. Authenticates (prompts for login if needed)
5. Uploads the HTML via a presigned URL
6. Confirms the upload

### First push vs subsequent pushes

**First push:**
- Assigns a `componentId` (UUID) and saves it to `myop.config.json`
- Adds the `organization` field to `myop.config.json`
- The component appears on the [Myop Dashboard](https://dashboard.myop.dev)

**Subsequent pushes:**
- Adds a new version to the existing component
- The latest version goes live immediately
- Previous versions remain accessible

### Dashboard URL

After pushing:
```
https://dashboard.myop.dev/dashboard/2.0/component/<componentId>
```

---

## Pull — Download a Component

`myop pull` downloads a component's latest version from the Myop platform.

```bash
# Pull using componentId from myop.config.json
npx myop pull

# Pull a specific component by ID
npx myop pull <componentId>

# Pull to a custom output path
npx myop pull <componentId> -o ./components/sidebar/index.html
```

### What happens during pull

1. Determines `componentId` from the argument or `myop.config.json`
2. Authenticates (prompts for login if needed)
3. Fetches the component HTML from Myop
4. Writes the HTML to the output path
5. Creates or updates `myop.config.json` with component metadata

### Output path logic

- If `-o <path>` is specified — writes to that path
- If `dist/index.html` exists — writes there
- Otherwise — writes to `index.html`

Parent directories are created automatically.

### Use cases

- **Clone a remote component** — `myop pull <id>` in an empty directory creates `index.html` + `myop.config.json`
- **Sync latest version** — `myop pull` in an existing component directory gets the latest remote version
- **Download to custom path** — use `-o` flag

---

## List — Browse & Batch Operations

`myop list` provides interactive search, multi-select, and batch pull or push for all components in your organization.

```bash
# Interactive browse
npx myop list

# Specify organization
npx myop list --org <orgId>
```

### How it works

1. Authenticates and loads your organizations
2. Resolves which org to use:
   - `--org <orgId>` flag takes precedence
   - Otherwise uses the saved default from `~/.myop/preferences.json`
   - If only one org, uses it automatically
   - If multiple orgs, prompts for selection
3. Fetches all components
4. Shows a **searchable** list — type to filter by name, press Enter to select, repeat
5. When done, choose:
   - **Pull** — downloads all selected components in parallel, each into its own subdirectory with `index.html` + `myop.config.json`
   - **Push** — scans local directories for matching `componentId`s and uploads in parallel

### Batch pull example

Clone an entire environment:

```bash
mkdir my-components && cd my-components
npx myop list
# Type to search, select components, choose Pull
# Each component gets its own subdirectory:
#   ./sidebar/index.html + myop.config.json
#   ./chart/index.html + myop.config.json
#   ./modal/index.html + myop.config.json
```

### Batch push example

Push all local changes at once:

```bash
cd my-components
npx myop list
# Select the components you've modified, choose Push
# Scans for matching componentIds in local directories
# Uploads all in parallel
```

### Organization memory

The selected organization is saved to `~/.myop/preferences.json` and reused automatically on subsequent runs. Use `--org <orgId>` to switch.

---

## Authentication

Push, pull, and list all require authentication. If you're not logged in, the CLI prompts automatically.

```bash
# Log in (opens browser for OAuth)
npx myop login

# Check who you're logged in as
npx myop whoami

# Log out
npx myop logout
```

Credentials are stored at `~/.myop/credentials.json` with `0o600` permissions. Tokens refresh automatically when expired.
