Skip to content
LykosJSLYKOSJS
CreatorDeveloperBenchmarkshomeGet started
v1.0.0
Modular architectureDependency injectionCLI generatorsWebSockets
PREVIOUSCLI generatorsNEXT JWT
© 2026 LykosJS · MIT LicenseBun · TypeScript

© 2026 LykosJS. Released under the MIT License.
Built by Zen Allaham.

DocsGitHubX
DOCS/V1.0.0/ARCHITECTURE
ARCHITECTURE

WebSockets

Build real-time applications with Socket.IO, natively integrated into the LykosJS server and dependency injection system.

Initialize Socket.IO

ts
1const io = app.socketIO({2  cors: {3    origin: 'https://app.example.com',4  },5})6 7io.on('connection', (socket) => {8  socket.emit('ready', { ok: true })9})

LykosJS provides built-in Socket.IO integration powered by @socket.io/bun-engine. Calling app.socketIO() creates and binds a Socket.IO server to the Bun engine. The default engine path is /socket.io/.

The integration is initialized only once per application instance. Subsequent calls to socketIO() return the existing Socket.IO server instead of creating another one.

Inject Socket.IO into modules

ts
1app.modules(Modules)

When modules are loaded, LykosJS automatically makes the initialized Socket.IO server available through the dependency injection container. You can inject the Socket.IO Server into your providers using its class as the injection token.

ts
1import { Server } from 'socket.io'2 3export class NotificationsService {4  constructor(private readonly io: Server) {}5 6  notify(userId: string, message: string) {7    this.io.to(userId).emit('notification', { message })8  }9}

You can also provide an explicit Socket.IO instance through the modules context:

ts
1app.modules(Modules, { io })
Initialize before loading modules
Call app.socketIO() before app.modules() when your modules depend on the Socket.IO server. Otherwise, provide an existing server explicitly through the modules context.

Start the server

ts
1app.listen(4000)

The HTTP server receives the Socket.IO integration automatically when it starts, allowing HTTP routes and real-time connections to run through the same LykosJS application.