# ChatClientService

The `ChatClient` service connects the user to the Stream chat.

## Properties

### appSettings$

**appSettings$**: `Observable<undefined | AppSettings>`

Emits the current [application settings](/chat/docs/javascript/app-setting-overview/). Since getting the application settings is an expensive API call and we don't always need the result, this is not initialized by default, you need to call `getApplicationSettings` to load them.

#### Defined in

[projects/stream-chat-angular/src/lib/chat-client.service.ts:44](https://github.com/GetStream/stream-chat-angular/blob/b8e03ec6da285f5e7c533ce710ebb946cded1190/projects/stream-chat-angular/src/lib/chat-client.service.ts#L44)

---

### chatClient

**chatClient**: `StreamChat`

The [StreamChat client](https://github.com/GetStream/stream-chat-js/blob/master/src/client.ts) instance. In general you shouldn't need to access the client, but it's there if you want to use it.

#### Defined in

[projects/stream-chat-angular/src/lib/chat-client.service.ts:33](https://github.com/GetStream/stream-chat-angular/blob/b8e03ec6da285f5e7c533ce710ebb946cded1190/projects/stream-chat-angular/src/lib/chat-client.service.ts#L33)

---

### connectionState$

**connectionState$**: `Observable<"offline" | "online">`

Emits the current connection state of the user (`online` or `offline`)

#### Defined in

[projects/stream-chat-angular/src/lib/chat-client.service.ts:48](https://github.com/GetStream/stream-chat-angular/blob/b8e03ec6da285f5e7c533ce710ebb946cded1190/projects/stream-chat-angular/src/lib/chat-client.service.ts#L48)

---

### events$

**events$**: `Observable<ClientEvent>`

Emits [`ClientEvent`](https://github.com/GetStream/stream-chat-angular/blob/master/projects/stream-chat-angular/src/lib/chat-client.service.ts) events. The platform documentation covers [the list of client, user presence and notification events](/chat/docs/javascript/event-object/).
:::important
For performance reasons this Observable operates outside of the Angular change detection zone. If you subscribe to it, you need to manually reenter Angular's change detection zone, our [Change detection guide](/chat/docs/sdk/angular/concepts/change-detection/) explains this in detail.
:::

#### Defined in

[projects/stream-chat-angular/src/lib/chat-client.service.ts:40](https://github.com/GetStream/stream-chat-angular/blob/b8e03ec6da285f5e7c533ce710ebb946cded1190/projects/stream-chat-angular/src/lib/chat-client.service.ts#L40)

---

### pendingInvites$

**pendingInvites$**: `Observable<Channel[]>`

Emits the list of pending invites of the user. It emits every pending invitation during initialization and then extends the list when a new invite is received. More information can be found in the [channel invitations](/chat/docs/sdk/angular/code-examples/channel-invites/) guide.

#### Defined in

[projects/stream-chat-angular/src/lib/chat-client.service.ts:52](https://github.com/GetStream/stream-chat-angular/blob/b8e03ec6da285f5e7c533ce710ebb946cded1190/projects/stream-chat-angular/src/lib/chat-client.service.ts#L52)

---

### user$

**user$**: `Observable<undefined | UserResponse | OwnUserResponse>`

Emits the current chat user

#### Defined in

[projects/stream-chat-angular/src/lib/chat-client.service.ts:56](https://github.com/GetStream/stream-chat-angular/blob/b8e03ec6da285f5e7c533ce710ebb946cded1190/projects/stream-chat-angular/src/lib/chat-client.service.ts#L56)

## Methods

### autocompleteUsers

**autocompleteUsers**(`searchTerm`): `Promise<UserResponse[]>`

Searches for users in the application that have ID or name matching the provided search term

#### Parameters

| Name         | Type     |
| :----------- | :------- |
| `searchTerm` | `string` |

#### Returns

`Promise<UserResponse[]>`

The users matching the search

#### Defined in

[projects/stream-chat-angular/src/lib/chat-client.service.ts:219](https://github.com/GetStream/stream-chat-angular/blob/b8e03ec6da285f5e7c533ce710ebb946cded1190/projects/stream-chat-angular/src/lib/chat-client.service.ts#L219)

---

### disconnectUser

**disconnectUser**(): `Promise<void>`

Disconnects the current user, and closes the WebSocket connection. Useful when disconnecting a chat user, use in combination with [`reset`](/chat/docs/sdk/angular/services/ChannelService/#reset/).

#### Returns

`Promise<void>`

#### Defined in

[projects/stream-chat-angular/src/lib/chat-client.service.ts:181](https://github.com/GetStream/stream-chat-angular/blob/b8e03ec6da285f5e7c533ce710ebb946cded1190/projects/stream-chat-angular/src/lib/chat-client.service.ts#L181)

---

### flagMessage

**flagMessage**(`messageId`): `Promise<void>`

Flag the message with the given ID. If you want to know [more about flags](/chat/docs/javascript/moderation/) check out the platform documentation.

#### Parameters

| Name        | Type     |
| :---------- | :------- |
| `messageId` | `string` |

#### Returns

`Promise<void>`

#### Defined in

[projects/stream-chat-angular/src/lib/chat-client.service.ts:210](https://github.com/GetStream/stream-chat-angular/blob/b8e03ec6da285f5e7c533ce710ebb946cded1190/projects/stream-chat-angular/src/lib/chat-client.service.ts#L210)

---

### getAppSettings

**getAppSettings**(): `Promise<void>`

Loads the current [application settings](/chat/docs/javascript/app-setting-overview/), if the application settings have already been loaded, it does nothing.

#### Returns

`Promise<void>`

#### Defined in

[projects/stream-chat-angular/src/lib/chat-client.service.ts:191](https://github.com/GetStream/stream-chat-angular/blob/b8e03ec6da285f5e7c533ce710ebb946cded1190/projects/stream-chat-angular/src/lib/chat-client.service.ts#L191)

---

### init

**init**(`apiKey`, `userOrId`, `userTokenOrProvider`, `clientOptions?`): `ConnectAPIResponse`

Creates a [`StreamChat`](https://github.com/GetStream/stream-chat-js/blob/668b3e5521339f4e14fc657834531b4c8bf8176b/src/client.ts#L124) instance using the provided `apiKey`, and connects a user with the given meta data and token. More info about [connecting users](/chat/docs/javascript/init-and-users/) can be found in the platform documentation.

#### Parameters

| Name                  | Type                                                                      | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| :-------------------- | :------------------------------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `apiKey`              | `string`                                                                  |                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `userOrId`            | `undefined` \| `string` \| `UserResponse` \| `OwnUserResponse`            | you can emit this for anonymous logins                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `userTokenOrProvider` | `TokenOrProvider`                                                         | You can provide:<ul> <li> a token, </li> <li> a token provider, a method that returns `Promise<string>`, which can be called when the previous token expires (recommended setup for production applications)</li> <li> the keyword 'guest' to connect as [guest user](/chat/docs/javascript/authless-users/#guest-users) </li> <li> the keyword 'anonymous' to connect as [anonymous user](/chat/docs/javascript/authless-users/#anonymous-users) </li> </ul> |
| `clientOptions?`      | `AxiosRequestConfig<any> & {} & { trackPendingChannelInvites?: boolean }` | Setting to provide to the Stream client instance                                                                                                                                                                                                                                                                                                                                                                                                              |

#### Returns

`ConnectAPIResponse`

#### Defined in

[projects/stream-chat-angular/src/lib/chat-client.service.ts:93](https://github.com/GetStream/stream-chat-angular/blob/b8e03ec6da285f5e7c533ce710ebb946cded1190/projects/stream-chat-angular/src/lib/chat-client.service.ts#L93)


---

This page was last updated at 2026-06-17T21:05:30.355Z.

For the most recent version of this documentation, visit [https://getstream.io/chat/docs/sdk/angular/services/ChatClientService/](https://getstream.io/chat/docs/sdk/angular/services/ChatClientService/).