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

# ClientWorker

> API reference for the ClientWorker class representing a worker

The `ClientWorker` class represents a worker (the Uplink SDK running on a physical device) connected to your Uplink session. It provides methods for managing browsers on the worker and querying device information.

<Info>
  A **worker** is an instance of the Uplink SDK running on a physical iOS or Android device. A device can create multiple workers when connecting to sessions.
</Info>

## Browser operations

### `worker.launch()`

Launches a new browser on this worker. Used when listening for `worker-connected` events from the `Client` class.

```typescript theme={null}
worker.launch(): Promise<Browser>
```

**Returns:** `Promise<Browser>` - New browser instance

**Example:**

```typescript theme={null}
client.on('worker-connected', async (worker) => {
  const browser = await worker.launch()
  const page = await browser.newPage()
  await page.goto('https://example.com')
  await page.close()
  await browser.close()
  await client.close()
})
```

### `worker.browsers()`

Lists all browsers currently running on this worker.

```typescript theme={null}
worker.browsers(): Promise<Browser[]>
```

**Returns:** `Promise<Browser[]>` - Array of browser instances

**Example:**

```typescript theme={null}
const browsers = await worker.browsers()

console.log(`${browsers.length} browsers on this worker`)

for (const browser of browsers) {
  const pages = await browser.pages()
  console.log(`Browser ${browser.handle} has ${pages.length} pages`)
}
```

## Device information

### `worker.getDeviceInfo()`

Gets device information including model, platform, and OS version.

```typescript theme={null}
worker.getDeviceInfo(): Promise<WorkerInfo>
```

**Returns:** `Promise<WorkerInfo>` - Device information object

**Example:**

```typescript theme={null}
const info = await worker.getDeviceInfo()

console.log('Device model:', info.deviceModel)      // "iPhone 14 Pro"
console.log('Platform:', info.platform)             // "iOS"
console.log('OS version:', info.platformVersion)    // "17.2"
console.log('Type:', info.deviceType)              // "phone"
```

### WorkerInfo type

```typescript theme={null}
interface WorkerInfo {
  deviceModel: string      // Device model name
  platform: string         // "iOS" or "Android"
  platformVersion: string  // OS version number
  deviceType: string       // "phone" or "tablet"
}
```

## Worker management

### `worker.terminate()`

Terminates this worker's connection to the session.

```typescript theme={null}
worker.terminate(): Promise<void>
```

**Returns:** `Promise<void>`

**Example:**

```typescript theme={null}
await worker.terminate()
console.log('Worker terminated')
```

<Warning>
  Terminating a worker closes all browsers running on it and disconnects the device from the session. This action cannot be undone.
</Warning>

## Properties

### `worker.address`

The unique hex-encoded address identifier for this worker.

```typescript theme={null}
worker.address: Address  // Hex-encoded worker address
```

## Related

<CardGroup cols={2}>
  <Card title="Client" icon="plug" href="/api-reference/client">
    Session and connection management
  </Card>

  <Card title="Browser" icon="browser" href="/api-reference/browser">
    Browser operations
  </Card>

  <Card title="Device management" icon="mobile" href="/fundamentals/device-management">
    Device management patterns
  </Card>

  <Card title="Core concepts" icon="book" href="/fundamentals/core-concepts">
    Architecture overview
  </Card>
</CardGroup>
