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

# Function: addEventSubscription()

> **addEventSubscription**(`streamerId`, `subscriptionType?`): `Promise`\<[`TwitchEventSubResult`](/documentation/api/twitch-helpers/interfaces/TwitchEventSubResult)>

Defined in: [twitch.ts:131](https://github.com/wolfstar-project/stars-components/blob/5aefd164bc5fc41e5a35d3abf908c288163dd354/packages/twitch-helpers/src/lib/twitch.ts#L131)

Adds a new Twitch subscription.

## Parameters

### streamerId

`string`

The Twitch ID of the streamer to subscribe to. You can use [fetchUsers](/documentation/api/twitch-helpers/functions/fetchUsers) to get the user information.

### subscriptionType?

[`TwitchEventSubTypes`](/documentation/api/twitch-helpers/enumerations/TwitchEventSubTypes) = `TwitchEventSubTypes.StreamOnline`

The type of subscription to add.

## Returns

`Promise`\<[`TwitchEventSubResult`](/documentation/api/twitch-helpers/interfaces/TwitchEventSubResult)>

If successful the result of the Twitch subscription, this contains the `id` that can be stored in a database
for reference. Otherwise an HttpError is thrown.

## Remarks

This requires `process.env.TWITCH_EVENTSUB_CALLBACK` and `process.env.TWITCH_EVENTSUB_SECRET` to be set.
