---
source_url: https://www.pubnub.com/docs/sdks/lua/api-reference/presence
title: Presence API for Lua SDK
updated_at: 2026-06-22T14:40:07.840Z
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# Presence API for Lua SDK

Presence lets you track who is online or offline and store custom state information. Presence shows:

* When a user has joined or left a channel
* How many users are subscribed to a particular channel (occupancy)
* Which channels a user or device is subscribed to
* Presence state associated with these users

## Here now

:::warning Requires Presence
This method requires that the Presence add-on is [enabled](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-) for your key in the [Admin Portal](https://admin.pubnub.com/).
:::

This method returns information about the current state of a channel, including a list of unique user IDs (universally unique identifiers, UUIDs) currently subscribed to the channel and the total occupancy count of the channel.

:::note Cache
This method has a 3-second response cache time.
:::

### Method(s)

To call `Here Now` you can use the following method(s) in the Lua SDK:

```lua
pubnub_obj:here_now(params)
```

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| params | table | Yes |  | Table of `here-now` parameters. See [Here Now Parameters](#here-now-parameters) for more details. |

#### Here now parameters

| Parameter | Description |
| --- | --- |
| `channel`Type: stringDefault: `none` | The channel to get presence for - if not provided, get global presence. |
| `callback` *Type: function(r)Default: `none` | The function to call on success with result. |
| `error`Type: function(r)Default: `function(r) end` | The function to call on failure, with result. |

### Sample code

#### Get a list of uuids subscribed to channel

```lua
pubnub_obj:here_now({
    channel = "demo",
    callback = function(response)
        textout(response)
    end,
    error = function (response)
        textout(response)
    end
})
```

## Where now

:::warning Requires Presence
This method requires that the Presence add-on is [enabled](https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-) for your key in the [Admin Portal](https://admin.pubnub.com/).
:::

This method returns the list of channels a UUID is subscribed to.

:::note Timeout events
If the app restarts (or the page refreshes) within the heartbeat window, no timeout event is generated.
:::

### Method(s)

To call `where_now()` you can use the following method(s) in the Lua SDK:

```lua
pubnub_obj:where_now(params)
```

| Parameter | Description |
| --- | --- |
| `params` *Type: table | Table of where-now parameters. See [Where Now Parameters](#where-now-parameters) for more details. |

#### Where now parameters

| Parameter | Description |
| --- | --- |
| `UUID`Type: stringDefault: `UUID of the object` | The UUID to get presence for. |
| `callback` *Type: function(r)Default: `none` | The function to call on success with result. |
| `error`Type: function(r)Default: `function(r) end` | The function to call on failure, with result. |

### Sample code

You simply need to define the `uuid` and the `callback` function to be used to send the data to as in the example below.

#### Get a list of channels a UUID is subscribed to

```lua
pubnub_obj:where_now({
    callback = function(response)
        textout(response)
    end,
    error = function (response)
        textout(response)
    end
})
```