Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Build a Realtime Chat App with Laravel 11, Vue 3 and Pinia
Rating: 4.6 out of 5(16 ratings)
93 students

Build a Realtime Chat App with Laravel 11, Vue 3 and Pinia

Learn how to build a realtime chat app with Laravel 11, Vue 3, Inertia and Reverb, using Pinia for state management
Created byTapan Sharma
Last updated 4/2025
English

What you'll learn

  • Learn how to Integrate Laravel with Reverb to build Real-Time Applications
  • Learn how to display user typing events using Whisper and implement Client-to-Client communication
  • Learn how to use presence channels to show online users for each room
  • Learn how to use the Intersection Observer API to automatically load previous chat messages
  • Learn State management with Pinia
  • Learn how to use flexbox tricks to keep messages scrolled into view as they roll in
  • Learn how to listen for Broadcasted events from the backend and react to them accordingly
  • Learn how to listen for users leaving or joining events and add/remove them from the online user list

Course content

1 section21 lectures3h 0m total length
  • Installing Laravel2:19
  • Scaffolding Chat Rooms9:35
  • Let's work on the Chat UI3:30
  • Building the Chat TextArea10:07

    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.

  • Seeding Fake Messages in Order10:15
  • Creating a Pinia Store6:27
  • Creating the Messages Endpoint6:24
  • Fetching Messages into our Store5:03

    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.

  • Displaying the Messages10:56
  • Ordering Messages with Flexbox4:49
  • Using the Intersection Observer API9:08

    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.

  • Fetching and Pushing Previous Messages9:58
  • Storing and Appending Messages11:21

    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.

  • Setting up Laravel Reverb6:17
  • Broadcasting new Messages18:11

    Broadcast new messages in real time using Laravel 11, Vue 3 and Pinia via Laravel Reverb, WebSockets, and a presence room channel.

  • Handling Broadcasted Messages in our Store7:26
  • Fetching Online Users5:50
  • Storing Online User State8:33
  • Keeping Online Users in Sync8:22

    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.

  • Detecting Typing Events7:35

    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.

  • Showing when a User is Typing18:45

    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.

Requirements

  • Beginner level knowledge of PHP/Laravel and VueJS is Required

Description

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.

Who this course is for:

  • Laravel Developers who want to Build Realtime Applications using InertiaJS, Vue 3 and Reverb