---
source_url: https://www.pubnub.com/docs/sdks/redux/api-reference/memberships
title: Memberships
updated_at: 2026-05-25T11:29:04.441Z
---

> 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


# Memberships

When a user joins a channel, an association called a *Membership* is stored between the User and the Channel. Application users can immediately see which channels they belong to, join or leave channels to create these memberships, and access information about other users and channels.

## State shape

The data about Memberships is stored from the perspective of Users and Channels in a normalized structure. The following example shows the shape of Memberships in the store:

```json
{
  "byId": {
    "user_53bbe00387004010a8b9ad5f36bdd4a7": [
      {
        "id": "channel_ac4e67b98b34b44c4a39466e93e",
        "custom": {
          "admin": true
        }
      }
    ]
  }
}
```

## 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.

### createMembershipReducer

`createMembershipReducer` instantiates a reducer in the store that responds to actions dispatched to update the state of a user's memberships, and all channel memberships, in the store.

```tsx
createMembershipReducer();
```

## 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.

### createMembershipListener

`createMembershipListener` registers a listener in the store that monitors Membership events.

A sample implementation of a single listener:

```tsx
pubnub.addListener(createMembershipListener(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.

### fetchMemberships

Get the specified user's channel memberships.

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

#### fetchMemberships arguments

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

#### fetchMemberships FetchMembershipRequest properties

| Property | Description |
| --- | --- |
| `uuid` *Type: `string`Default: n/a | The ID of the user whose memberships you wish to retrieve. |
| `limit`Type: `number`Default: 100 | Maximum number of results to return per page |
| `filter`Type: `string`Default: n/a | Expression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is [defined here](https://www.pubnub.com/docs/general/metadata/filtering). |
| `sort`Type: `string`Default: n/a | Key-value pair of a property to sort by, and a sort direction. Available options are `updated`, `channel.id`, `channel.name`, and `channel.updated`. Use `asc` or `desc` to specify sort direction, or specify `null` to take the default sort direction (ascending). For example: `{channel.name: 'asc'}` |
| `page`Type: `object`Default: n/a | To get the next set of results, specify next. To get the previous set of results, specify prev. If you specify both, prev is ignored. `{` `next: "next-page-id"`, `prev: "prev-page-id"` `}` |
| `include`Type: `object`Default: `{` `customFields:` `false,` `channelFields:` `false,` `customChannelFields:` `false,` `totalCount`: `false` `}` | Specifies whether to include custom fields in the response, and whether to include a total result count. |

#### fetchMemberships sample usage

```javascript
dispatch(fetchMemberships({
  uuid: 'user_53bbe00387004010a8b9ad5f36bdd4a7',
  limit: '2'
}));
```

### setMemberships

Set memberships of user to a list of channels.

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

#### setMemberships arguments

| Parameter | Description |
| --- | --- |
| `request` *Type: `MembershipRequest` | Membership request parameter object. |
| `[meta]`Type: `object` | Standard meta options object. |

#### setMemberships MembershipRequest properties

| Property | Description |
| --- | --- |
| `uuid` *Type: `string`Default: n/a | The ID of the user. |
| `channels` *Type: Array of `object`sDefault: n/a | Array of objects indicating the channels(s) to be joined, along with optional custom data. `[` `{` `id: "channel-id-1"` `custom: { ... }` `},` `{` `id: "channel-id-2"` `custom: { ... }` `},` `]` |
| `limit`Type: `number`Default: 100 | Maximum number of results to return per page |
| `filter`Type: `string`Default: n/a | Expression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is [defined here](https://www.pubnub.com/docs/general/metadata/filtering). |
| `sort`Type: `string`Default: n/a | Key-value pair of a property to sort by, and a sort direction. Available options are `updated`, `channel.id`, `channel.name`, and `channel.updated`. Use `asc` or `desc` to specify sort direction, or specify `null` to take the default sort direction (ascending). For example: `{channel.name: 'asc'}` |
| `page`Type: `object`Default: n/a | To get the next set of results, specify next. To get the previous set of results, specify prev. If you specify both, prev is ignored. `{` `next: "next-page-id"`, `prev: "prev-page-id"` `}` |
| `include`Type: `object`Default: `{` `customFields:` `false,` `channelFields:` `false,` `customChannelFields:` `false,` `totalCount`: `false` `}` | Specifies whether to include custom fields in the response, and whether to include a total result count. |

#### setMemberships sample usage

```javascript
dispatch(setMemberships({
  uuid: 'user_53bbe00387004010a8b9ad5f36bdd4a7',
  channels: [ { id: 'channel_ac4e67b98b34b44c4a39466e93e' } ]
}));
```

### removeMemberships

Remove a user from a list of channels.

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

#### removeMemberships arguments

| Parameter | Description |
| --- | --- |
| `request` *Type: `MembershipRequest` | Membership request parameter object. |
| `[meta]`Type: `object` | Standard meta options object. |

#### removeMemberships MembershipRequest properties

| Property | Description |
| --- | --- |
| `uuid` *Type: `string`Default: n/a | The ID of the user. |
| `channels` *Type: Array of `strings`sDefault: n/a | Array of channels(s) to leave. `["channel-id-1","channel-id-2"]` |
| `limit`Type: `number`Default: 100 | Maximum number of results to return per page |
| `filter`Type: `string`Default: n/a | Expression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is [defined here](https://www.pubnub.com/docs/general/metadata/filtering). |
| `sort`Type: `string`Default: n/a | Key-value pair of a property to sort by, and a sort direction. Available options are `updated`, `channel.id`, `channel.name`, and `channel.updated`. Use `asc` or `desc` to specify sort direction, or specify `null` to take the default sort direction (ascending). For example: `{channel.name: 'asc'}` |
| `page`Type: `object`Default: n/a | To get the next set of results, specify next. To get the previous set of results, specify prev. If you specify both, prev is ignored. `{` `next: "next-page-id"`, `prev: "prev-page-id"` `}` |
| `include`Type: `object`Default: `{` `customFields:` `false,` `channelFields:` `false,` `customChannelFields:` `false,` `totalCount`: `false` `}` | Specifies whether to include custom fields in the response, and whether to include a total result count. |

#### removeMemberships sample usage

```javascript
dispatch(removeMemberships({
  uuid: 'user_53bbe00387004010a8b9ad5f36bdd4a7',
  channels: [ 'channel_ac4e67b98b34b44c4a39466e93e' ]
}));
```