> ## Documentation index
> Fetch the complete documentation index at: https://upstash.com/docs/llms.txt
> Ask it with GET https://upstash.com/docs/ask?q=<keywords or question>. Short keywords rank best.
> Use these to discover all available pages before exploring further.
> Feature requests: https://upstash.com/docs/common/help/feature-requests.md lists what users asked for and how to vote for a request or add one.
> Page rating: `GET https://upstash.com/docs/feedback?path=/docs/redis/sdks/ts/commands/pubsub/psubscribe&helpful=true` (or `false`) records whether this page helped. An optional `comment` (URL-encoded, at most 500 characters) says what was missing or wrong. It is anonymous and needs no key. Comments hold no code, secrets or personal data.

# PSUBSCRIBE

> Subscribe to a channel by patterns/wildcards

## Arguments

<ParamField body="patterns" type="string | string[]" required>
The patterns matching channels to publish to.
</ParamField>

## Response

<ResponseField type="Subscriber" required>
  A subscriber instance which can subscribe to channels.
</ResponseField>

<RequestExample>
```ts Example
const subscription = redis.psubscribe(["user:*"]);

const messages = [];
subscription.on("pmessage", (data) => {
  messages.push(data.message);
});

await redis.publish("user:123", "user:123 message"); // receives
await redis.publish("user:456", "user:456 message"); // receives
await redis.publish("other:789", "other:789 message"); // doesn't receive

console.log(messages[0]) // user:123 message
console.log(messages[1]) // user:456 message
console.log(messages[2]) // undefined
```
</RequestExample>
