[Answered ]-Get the current chat history after page refresh

1👍

Try using cookies and set the expiry of them for a very long time.

0👍

You need a "history" function.

Assuming you can uniquely identify chats between folks, you can publish the last N messages in history for the users on connect, giving a seamless experience controlled from the server side.
This can be complex, but assuming your frontend can re-order it it works great.

Failing that, create an API route for this where a user can query their chat ID and get the last N messages OR the messages with timestamps between the queried period.

All this is easier if you have some kind of time series database for storing the chat, as they are all about fast insertion and time centric query tools. QuestDB is awesome for this.

This is how we’ve implemented Rewind and History in Ably, and it’s used for many large scale chat applications.

Leave a comment