Skip to content

Simple Chat-app utilizing Nextjs, Socket.io and Supabase

Notifications You must be signed in to change notification settings

Ryalcantara/chat-app

Repository files navigation

Next.js Chat App (WIP)

🚀 Initial Implementation with Socket.io WebSockets and Supabase Data

This chat application leverages Socket.io for real-time communication and Supabase for data management.

📡 Socket.io Communication Flow

  • socket.emit ➡️ Send Data
    • From: Client or Server
    • To: Server or Client
    • Usage: socket.emit is used to send data to the server or from the server to the client. This method allows for initiating communication from either the client or the server side.
// Client-side example
socket.emit('message', { user: 'John', message: 'Hello, world!' });

// Server-side example
socket.emit('update', { status: 'New user connected!' });
  • socket.on ⬅️ Receive Data

    • From: Server or Client
    • To: Client or Server
    • Usage: socket.on is used to listen for data sent from the server or client. This allows both the client and server to react to incoming messages or events.
// Client-side example
socket.on('message', (data) => {
  console.log('Received message:', data);
});

// Server-side example
socket.on('update', (data) => {
  console.log('Received update:', data);
});

🔄 Summary of Socket.io Functions

  • socket.emit:

    • Function: Sends data or events.
    • Direction: Bidirectional (Client ➡️ Server or Server ➡️ Client).
  • socket.on:

    • Function: Listens for incoming data or events.
    • Direction: Bidirectional (Client ⬅️ Server or Server ⬅️ Client).

About

Simple Chat-app utilizing Nextjs, Socket.io and Supabase

Resources

Stars

Watchers

Forks