# Logging Out

User can be logged out by disconnecting the user. After disconnection, call connect user for logging in with another user.

<codetabs>

<codetabs-item value="kotlin" label="Kotlin">

```kotlin
val user = User()
val token = "token"

client.disconnect(flushPersistence = false).enqueue { disconnectResult ->
  if (disconnectResult.isSuccess) {
    client.connectUser(user, token).enqueue { /* ... */ }
  } else {
    // Handle Result.Failure
  }
}
```

</codetabs-item>

<codetabs-item value="javascript" label="JavaScript">

```js
await client.disconnectUser();
await client.connectUser(
  {
    id: "jack",
    name: "Jack Doe",
  },
  "{{ chat_user_token }}",
);
```

</codetabs-item>

<codetabs-item value="swift" label="Swift">

```swift
// Disconnect from web-socket events, but keep the offline state
chatClient.disconnect {
  // …
}
// or
await chatClient.disconnect()

// Disconnect from web-socket events and delete the offline state
chatClient.logout {
  // …
}
// or
await chatClient.logout()
```

</codetabs-item>

<codetabs-item value="dart" label="Dart">

```dart
await client.disconnect();

await client.connectUser(otherUser, "{{ chat_user_token }}");
```

</codetabs-item>

<codetabs-item value="unreal" label="Unreal">

```cpp
Client->DisconnectUser();

const FString Token{TEXT("{{ api_key }}")};
const FUser OtherUser{TEXT("tommaso")};
Client->ConnectUser(
  OtherUser,
  Token,
  [](const FOwnUser& UserRef)
  {
    // New connection established
  });
```

</codetabs-item>

<codetabs-item value="java" label="Java">

```java
User user = new User();
String token = "token";

client.disconnect(true).enqueue(disconnectResult -> {
  if (disconnectResult.isSuccess()) {
    client.connectUser(user, token).enqueue(loginResult -> { /* ... */ });
  } else {
    // Handle result.error()
  }
});
```

</codetabs-item>

<codetabs-item value="unity" label="Unity">

```csharp
await client.DisconnectUserAsync();
```

</codetabs-item>

</codetabs>

## Disable Push Notifications

Additionally, you'll want to stop the user from receiving further push notifications by [unregistering their device](/chat/docs/<framework>/push_devices/#unregister-a-device/).

---

This page was last updated at 2025-08-15T14:15:12.501Z.

For the most recent version of this documentation, visit [https://getstream.io/chat/docs/react-native/logout/](https://getstream.io/chat/docs/react-native/logout/).