> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/upstash/redis-js/llms.txt
> Use this file to discover all available pages before exploring further.

# SMEMBERS

> Get all members of a set

Returns all members of the set stored at key. If the key does not exist, an empty array is returned.

## Usage

```typescript theme={null}
await redis.smembers(key);
```

## Parameters

<ParamField body="key" type="string" required>
  The key of the set
</ParamField>

## Response

<ResponseField name="result" type="TData[]">
  An array containing all members of the set
</ResponseField>

## Examples

### Get all members

```typescript theme={null}
await redis.sadd("myset", "hello", "world");
const members = await redis.smembers("myset");
console.log(members); // ["hello", "world"]
```

### Get members from empty set

```typescript theme={null}
const members = await redis.smembers("nonexistent");
console.log(members); // []
```

### Using with custom types

```typescript theme={null}
await redis.sadd("numbers", 1, 2, 3, 4, 5);
const members = await redis.smembers<number[]>("numbers");
console.log(members); // [1, 2, 3, 4, 5]
```

### Working with user data

```typescript theme={null}
await redis.sadd("users:online", "user:1", "user:2", "user:3");
const onlineUsers = await redis.smembers("users:online");
console.log(onlineUsers); // ["user:1", "user:2", "user:3"]
```
