
Replace the default text input with a text area to enable enter submissions and shift-enter for new lines, emitting messages to the parent for backend storage.
Fetch messages from the backend using the rooms/{roomSlug}/messages API with axios in the Pinia store, supporting pagination, merging data, and enabling infinite scrolling.
Enable infinite scrolling using the intersection observer from Vue use to load additional data from the backend when the watched element enters the viewport, then merge it with existing messages.
Implement infinite scrolling to fetch and merge messages, store a new message on enter via the backend, and append it to the timeline with room and user IDs.
Broadcast new messages in real time using Laravel 11, Vue 3 and Pinia via Laravel Reverb, WebSockets, and a presence room channel.
Sync online user lists in real time by listening to join and leave events on the channel, updating the users store with add and remove actions, and preventing duplicates.
Register a keydown listener on the text area to emit a typing event, and display a typing indicator in the navbar with a three second timeout.
Seamlessly implement client-to-client typing indicators by whispering typing events over a presence channel with Laravel Echo, updating the typing state for other connected users without backend requests.
Using the power of Laravel Reverb, let’s build a real-time multi-room chat application with Laravel 11 and VueJS with InertiaJS, pulling in Pinia for state management.
We’ll cover:
Using the Intersection Observer API to load previous chat messages automatically when the user scrolls to the top of the chat interface
Learn how to Use presence channels to show online users for each room
Learn how to implement Client-to-client communication using Laravel Echo to show who’s typing and display the typing indicators accordingly
Learn how to use Flexbox tricks to keep messages scrolled into view as they roll in
Learn database seeding techniques in Laravel
Learn how to use API Resources in Laravel
Learn how to display better-formatted dates and times
Learn how to listen for Broadcasted events from the backend and react to them accordingly
We'll also learn how to listen for users leaving or joining events and add/remove them from the online user list
All of this state will be managed on the client side, using Pinia
By the end of this course, you will have built a feature-rich, real-time chat application that showcases your understanding of front-end and back-end technologies, perfect for any aspiring developer looking to enhance their skills in dynamic web application development.