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

# Client.subscribe()

Subscribe to topics synchronously.

## Signature

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

```javascript
client.subscribe(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)         |
