Advice on switching the user between multiple Sendbird apps

What is the advice on managing the Sendbird connection when a user switches between different user IDs?

We have a React Native app accompanying a SaaS web app that we sell to small businesses. We create a separate Sendbird app for each of these customer businesses to keep chats limited to the employees of that business. However, the end user has a single email-based login for our system and we allow them to potentially switch between multiple businesses while using our app (similar to belonging to multiple orgs in Slack) and so I need to switch that user between multiple Sendbird apps.

This seems straightforward enough, just need to call connect(sendbirdUserId, { accessToken: currentOrgChatSessionToken }) with the relevant variables for that Sendbird app/business. I’m just looking for some confirmation on whether there is any cleanup needed when calling connect() again to switch user ids. Do I need to call disconnect() in between? Are there any other considerations for managing a multi-tenant environment?

Hello @Ben_Winters

Welcome to the Sendbird Community!

In a multi-tenant environment where users switch between different user IDs, it is recommended to call the disconnect() method before calling the connect() method with the new user ID. This ensures that the previous connection is properly closed before establishing a new connection.

Additionally, you should also consider managing the access tokens or session tokens for each user and their corresponding Sendbird app. When switching between user IDs, you should provide the relevant access token or session token for the corresponding Sendbird app in the connect() method.

It is also important to note that each Sendbird app has its own concurrent connection limit. Therefore, you should ensure that the number of connections from a single user ID across all Sendbird apps does not exceed the limit.

Overall, the recommended approach for managing the Sendbird connection when switching between different user IDs in a multi-tenant environment is to disconnect the current user, provide the relevant access token or session token for the new user, and then connect to the Sendbird server with the new user ID.

Let me know if this helps in clarifying a few things here.

Thank you very much Chinmaya. That part about needing to call disconnect() when switching apps was the information I was looking for.