# Migrating from Socket.IO or Firebase

Many teams start with a chat they built on Socket.IO or Firebase and move to Stream Chat once they need history, unread counts and notifications. This page answers whether to keep building or switch, and shows how to move users and message history to Stream Chat while older versions of your app keep working.

## We built basic chat with Socket.IO. Now we need message history, unread counts and notifications for offline users. Should we keep building it or switch to a chat API, and which one?

Socket.IO moves events between your server and connected clients, and Firebase stores documents and syncs them to clients. Neither knows what a conversation, a member or an unread message is, so everything after "deliver this message now" is code you write and run. Stream Chat ships these parts as an API with server SDKs and UI components:

| You need                        | Building it yourself                                                                                             | Stream Chat                                                                                                                                                                                                              |
| ------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Message history                 | Store every message, page through it in order, and catch clients up after they reconnect.                        | Every message is stored, and clients load history page by page. See [Channel Pagination](https://getstream.io/chat/docs/dotnet-csharp/channel-pagination/).                                                                                     |
| Unread counts                   | Keep a read position per user and conversation, count the messages after it, and keep it in step across devices. | Unread counts per channel and in total, kept in step across a user's devices. See [Unread Counts](https://getstream.io/chat/docs/dotnet-csharp/unread/) and [Delivered & Read Status](https://getstream.io/chat/docs/dotnet-csharp/message-delivery-and-read-status/). |
| Notifications for offline users | Store device tokens, work out who should be notified, and call APNs and Firebase Cloud Messaging.                | Push for new messages through your APNs and Firebase credentials, to every member or only to those who are offline. See [Push Notifications](https://getstream.io/docs/platform/push-notifications/).                                        |
| Threads, reactions and search   | Model them in your database and add an index for search.                                                         | Built in. See [Threads & Replies](https://getstream.io/chat/docs/dotnet-csharp/threads/) and [Message Search](https://getstream.io/chat/docs/dotnet-csharp/search/).                                                                                                   |
| Moderation                      | Build filters, flagging, bans and a review tool.                                                                 | Built in. See [Moderation for Chat](https://getstream.io/chat/docs/dotnet-csharp/moderation/).                                                                                                                                                  |

Keep building when chat stays small: messages that only matter while both people are online, with no history, unread counts or notifications. Once you need those, the work grows with every platform you support, because each client needs the same logic. Switch when chat isn't the product you want to spend your engineering time on.

To compare chat APIs, check that each one has client SDKs for every platform you ship, server SDKs for your backend language, a way to import your existing data, and a way to run it next to your current chat while you move. The next section shows how Stream Chat does the last two.

## We're changing chat providers and need to migrate users and message history while older versions of our mobile app keep working. Which providers make this easiest?

Pick a provider that can import your history and that you can run next to your current chat until the older app versions are gone. With Stream Chat, the move takes four steps:

1. Map your users, conversations and messages to Stream Chat [users, channels and messages](https://getstream.io/chat/docs/dotnet-csharp/migrating-from-sendbird/#field-mapping), and keep their IDs.
2. Mirror new messages between your old backend and Stream Chat in both directions.
3. Import the history.
4. Release app versions that use Stream Chat, and turn off the old backend once older versions are no longer in use.

Coming from Sendbird? Stream Chat can sync from Sendbird for you. See [Sendbird Migration](https://getstream.io/chat/docs/dotnet-csharp/migrating-from-sendbird/#sendbird-migration).

### Mirror new messages in both directions

Start mirroring before you export the history, so no message falls between the export and the switch. Users on older app versions keep talking to your old backend, users on new versions talk to Stream Chat, and both see every message.

First, create each user and conversation in Stream Chat when your old backend creates them, with the same IDs. See [Users](https://getstream.io/docs/platform/users/) and [Creating Channels](https://getstream.io/chat/docs/dotnet-csharp/creating-channels/).

Then, wherever your old backend stores a new message, such as your Socket.IO `message` handler or a Cloud Function that runs when Firebase stores a message, send it to Stream Chat with the same ID. The `mirrored_from` custom field marks it as a copy:

```csharp label="C#"
// messageId, roomId, senderId and text come from the message your old backend stored
await chat.SendMessageAsync("messaging", roomId, new SendMessageRequest
{
    Message = new MessageRequest
    {
        ID = messageId,
        Text = text,
        UserID = senderId,
        Custom = new Dictionary<string, object> { ["mirrored_from"] = "legacy" },
    },
});
```

Sending a message whose ID already exists fails with error code 4 ("a message with ID ... already exists"), so a retried mirror call never creates a duplicate. Treat that error as success.

For the other direction, subscribe to the [`message.new` webhook](https://getstream.io/chat/docs/dotnet-csharp/webhook-events/#messagenew) and write each new message to your old backend, which delivers it to older app versions as before. Custom fields sit directly on `message` in the webhook payload, so skip the messages that carry `mirrored_from`: they came from your old backend. When your old backend stores a message that came from Stream Chat, don't mirror it back.

```json
{
  "type": "message.new",
  "message": {
    "id": "legacy-msg-1042",
    "text": "Sent from the old app",
    "mirrored_from": "legacy"
  }
}
```

Each system sends push notifications to the devices registered with it. When a user updates to an app version that uses Stream Chat, [register the device](https://getstream.io/docs/platform/push-devices/) with Stream Chat and remove it from your old backend, so they aren't notified twice.

### Import the history

Export your users, conversations and messages from the old system to a [JSON Lines file](https://getstream.io/chat/docs/dotnet-csharp/import/#file-format), one item per line, and keep the IDs you use for mirroring:

```json
{"type":"user","data":{"id":"lena","name":"Lena"}}
{"type":"user","data":{"id":"omar","name":"Omar"}}
{"type":"channel","data":{"id":"room-1","type":"messaging","created_by":"lena"}}
{"type":"member","data":{"channel_type":"messaging","channel_id":"room-1","user_id":"lena"}}
{"type":"member","data":{"channel_type":"messaging","channel_id":"room-1","user_id":"omar"}}
{"type":"message","data":{"id":"legacy-msg-1041","channel_type":"messaging","channel_id":"room-1","user":"omar","text":"An older message","type":"regular","created_at":"2026-11-01T10:00:00Z"}}
```

Upload it with the [Stream CLI](https://getstream.io/cli/docs/) and follow the import until it finishes:

```bash label="Bash"
$ getstream import chat history.jsonl --watch
```

An import is an upsert by ID. A message that both the export and the mirror carry ends up once in Stream Chat, so the overlap between the two is safe. The file's data replaces the mirrored copy, custom fields included, so export each item in full. Try a small file first: [Importing Data](https://getstream.io/chat/docs/dotnet-csharp/import/) lists the file format, its validation rules and how members' unread counts are set.

### Switch the apps over

Release app versions that use the Stream Chat client SDKs. Your backend creates a [user token](https://getstream.io/docs/platform/authentication/) for each user, and the app connects with it. Older versions keep working through the mirror while users update.

When few users are left on older versions, ask them to update, stop the mirror and the webhook, and turn off the old backend. Stream Chat keeps the whole history.

## Going further

- [Migration Guide](https://getstream.io/chat/docs/dotnet-csharp/migrating-from-sendbird/): migration approaches, field mapping and Sendbird sync.
- [Importing Data](https://getstream.io/chat/docs/dotnet-csharp/import/): the import file format and the CLI.
- [Webhook Events](https://getstream.io/chat/docs/dotnet-csharp/webhook-events/): every event your backend can receive.
- [Unread Counts](https://getstream.io/chat/docs/dotnet-csharp/unread/): how Stream Chat counts unread messages.

---

For the most recent version of this documentation, visit [https://getstream.io/chat/docs/dotnet-csharp/migrating-from-socketio-firebase/](https://getstream.io/chat/docs/dotnet-csharp/migrating-from-socketio-firebase/).