Add real-time chat to your Node.js app in minutes — not hours.
Built on top of Socket.io with rooms, messaging, typing indicators, and read receipts ready out of the box.
npm install quick-socketconst http = require('http')
const express = require('express')
const quickSocket = require('quick-socket')
const app = express()
const server = http.createServer(app)
// Initialize — one line
const io = quickSocket.init(server)
server.listen(3000, () => {
console.log('Server running on port 3000')
})That's it. Your Socket.io server is ready.
- Create and manage chat rooms
- Send, edit and delete messages
- Typing indicators
- Read receipts (sent, delivered, read)
- Broadcast to all users
- Notify specific users or rooms
- Auth middleware support
quickSocket.createRoom('room-001', {
travellerId: 'user-1',
supplierId: 'user-2'
})io.on('connection', (socket) => {
quickSocket.joinRoom(socket, 'room-001', {
userId: 'user-1',
role: 'traveller'
})
})quickSocket.sendMessage('room-001', {
senderId: 'user-1',
content: 'Hello!',
type: quickSocket.MESSAGE_TYPES.TEXT
})// user started typing
quickSocket.sendTyping('room-001', 'user-1', true)
// user stopped typing
quickSocket.sendTyping('room-001', 'user-1', false)// mark one message as read
quickSocket.markRead('room-001', 'message-id', 'user-2')
// mark all messages as read
quickSocket.markAllRead('room-001', 'user-2')
// mark as delivered
quickSocket.markDelivered('room-001', 'message-id', 'user-2')quickSocket.editMessage('room-001', 'message-id', 'Updated text')
quickSocket.deleteMessage('room-001', 'message-id')// notify everyone
quickSocket.broadcast('announcement', { message: 'Server update soon' })
// notify a specific room
quickSocket.notifyRoom('room-001', 'alert', { message: 'New booking!' })
// notify a specific user
quickSocket.notifyUser('user-1', 'ping', { message: 'You have a message' })quickSocket.leaveRoom(socket, 'room-001')
quickSocket.closeRoom('room-001')Listen to these events on the client side:
| Event | When it fires |
|---|---|
message:new |
New message sent |
message:edited |
Message was edited |
message:deleted |
Message was deleted |
message:typing |
User is typing |
message:read |
Message was read |
message:delivered |
Message was delivered |
messages:all_read |
All messages marked read |
user:joined |
User joined the room |
user:left |
User left the room |
room:closed |
Room was closed |
// frontend (browser)
const socket = io('http://localhost:3000')
socket.on('message:new', (msg) => {
console.log('New message:', msg.content)
})
socket.on('message:typing', (data) => {
console.log(data.userId, 'is typing:', data.isTyping)
})
socket.on('message:read', (data) => {
console.log('Read by:', data.userId)
})quickSocket.MESSAGE_TYPES.TEXT // 'text'
quickSocket.MESSAGE_TYPES.IMAGE // 'image'
quickSocket.MESSAGE_TYPES.FILE // 'file'
quickSocket.MESSAGE_TYPES.SYSTEM // 'system'quickSocket.STATUS.SENT // 'sent'
quickSocket.STATUS.DELIVERED // 'delivered'
quickSocket.STATUS.READ // 'read'const io = quickSocket.init(server)
io.use(quickSocket.authMiddleware((token) => {
// verify your token here (JWT, etc.)
return verifyToken(token) // return user object
}))Client sends token like this:
const socket = io('http://localhost:3000', {
auth: { token: 'your-token-here' }
})const participants = quickSocket.getRoomParticipants('room-001')
console.log(participants)
// [{ userId, role, socketId, joinedAt }, ...]Contributions are welcome! Here's how you can help:
- Fix a bug
- Add TypeScript support
- Add Redis support for multi-server scaling
- Add a React.js example
- Improve documentation
Please read CONTRIBUTING.md to get started.
MIT