---
source_url: https://www.pubnub.com/docs/sdks/redux/api-reference/presence
title: Presence API
updated_at: 2026-06-19T11:38:30.548Z
---

> 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

Presence lets you track who is online or offline and store custom state information. When Presence is enabled, PubNub automatically creates a presence channel for each channel. Subscribing to a presence channel or presence channel group returns only presence events.

:::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/).
:::

## State shape

The data about Presence is stored as a list of spaces and the list of occupants (members) in each space. The following example shows the shape of Presence data in the store:

```json
{
 "byId": {
    "space_ac4e67b98b34b44c4a39466e93e": {
      "name": "space_ac4e67b98b34b44c4a39466e93e",
      "occupants": [
        {
          "uuid": "user_53bbe00387004010a8b9ad5f36bdd4a7"
        }
      ],
      "occupancy": 1
    }
 }
}
```

## Reducers

The PubNub Redux framework provides reducers your app can implement that respond to various actions that update the store. To track the state of a set of objects in the store, combine the reducers you want into the `rootReducer` for your app.

### createPresenceReducer

`createPresenceReducer` instantiates a reducer in the store that responds to actions dispatched to update the state of a user's presence in the store.

```tsx
createPresenceReducer();
```

## Listeners

The PubNub Redux framework includes listeners that monitor PubNub events from the server and dispatch corresponding actions. All listeners are automatically invoked if your app registers the combined PubNub listener. You can register only specific listeners, or implement your own combine listeners function.

### createPresenceListener

`createPresenceListener` registers a listener in the store that monitors Feature events.

A sample implementation of a single listener:

```tsx
pubnub.addListener(createPresenceListener(store.dispatch));
```

## Commands

The PubNub Redux framework provides commands that your app can dispatch to the store to be managed by the Thunk middleware. Commands interact with the PubNub API and dispatch basic actions which are then processed by reducers to update the state in the store.

### fetchHereNow

Obtain information about the current state of a channel, including a list of unique user IDs currently subscribed to the channel and the total occupancy count of the channel.

### fetchPresenceState

Get the current state information based on the current `uuid` for either specified `channels` or `channelGroups`.

```tsx
fetchPresenceState( request, [meta] );
```

#### fetchPresenceState arguments

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| request | PresenceStateRequest | Yes |  | Space request parameter object. |
| [meta] | object | Optional |  | Standard meta options object. |

#### fetchPresenceState PresenceStateRequest properties

| Property | Description |
| --- | --- |
| `uuid`Type: `string`Default: *current UUID* | The subscriber UUID to get the current state. |
| `channels`Type: ArrayDefault: n/a | Specifies the channels to get the state. Either `channels` or `channelGroups` should be specified. |
| `channelGroups`Type: ArrayDefault: n/a | Specifies the channels to get the state. Either `channels` or `channelGroups` should be specified. |

#### fetchPresenceState sample usage

```javascript
dispatch(fetchPresenceState({
  uuid: "user_53bbe00387004010a8b9ad5f36bdd4a7",
  channels: ['space_ac4e67b98b34b44c4a39466e93e'],
}));
```

```tsx
createPresenceReducer();
```

## Terms in this document

* **Channel** - A pathway for sending and receiving messages between devices, created automatically when you first use it, that can handle any number of users and messages for different communication needs, like 1-1 text chats, group conversations, and other data streaming.
* **Channel pattern** - A way to group and analyze channel data to track performance metrics like message counts and user engagement over time with PubNub Insights.
