This repository contains a simple demo application that integrates AdonisJS with Socket.IO, featuring user authentication. The project demonstrates how to set up a basic one-to-one chat application where users can log in, join chat rooms, and exchange messages in real-time.
- Socket.io singleton server
- Integration with
@adonisjs/auth
- User authentication (register, login)
- Groups (create and delete)
- Group members (list, join, leave, remove)
- Group messages (list, send)
- Private messages (list, send)
- Realtime notifications
- Inertia+React frontend
Access the socket.io server:
import Ws from '#services/socket'
const io = Ws.io // singleton instance
Access the current user in the socket context
Ws.io.on('connection', async (socket) => {
const user = socket.context.auth.getUserOrFail()
...
})