---
title: "Client.subscribeAsync( topic, [options] ) | Grafana k6 documentation"
description: "Subscribe to MQTT topics asynchronously"
---

# Client.subscribeAsync()

Subscribe to topics asynchronously. Returns a promise that resolves when the subscription is complete.

## Signature

JavaScript ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```javascript
await client.subscribeAsync(topic, options)
```

## Parameters

Expand table

| Parameter    | Type                | Description                                       |
|--------------|---------------------|---------------------------------------------------|
| topic        | string \| string\[] | Topic or array of topics to subscribe to          |
| options      | object              | Optional subscription configuration               |
| options.qos  | number              | Quality of Service level (0, 1, or 2). Default: 0 |
| options.tags | object              | Custom tags for metrics (key-value pairs)         |

## Returns

A promise that resolves when the subscription is successfully completed.
