{"id":46874,"library":"adonisjs-websocket","title":"AdonisJS Websocket","description":"Websocket provider for AdonisJS v6, version 0.2.3, actively maintained. Provides WebSocket route registration via router.ws(), middleware support, broadcasting, and controller-based handling. Integrates seamlessly with AdonisJS core, auth, and HTTP server. Alternative to socket.io with tighter AdonisJS integration.","status":"active","version":"0.2.3","language":"javascript","source_language":"en","source_url":"https://github.com/KABBOUCHI/adonisjs-websocket","tags":["javascript"],"install":[{"cmd":"npm install adonisjs-websocket","lang":"bash","label":"npm"},{"cmd":"yarn add adonisjs-websocket","lang":"bash","label":"yarn"},{"cmd":"pnpm add adonisjs-websocket","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer dependency for AdonisJS framework integration","package":"@adonisjs/core","optional":false},{"reason":"Required peer dependency for HTTP server context","package":"@adonisjs/http-server","optional":false}],"imports":[{"note":"WebSocketContext is only a type, use type import.","wrong":"import { WebSocketContext } from 'adonisjs-websocket'","symbol":"WebSocketContext","correct":"import type { WebSocketContext } from 'adonisjs-websocket'"},{"note":"Registered via AdonisJS router, no explicit import needed.","wrong":"","symbol":"router.ws()","correct":"router.ws('/path', handler)"},{"note":"broadcast() is async, must be awaited.","wrong":"ws.broadcast('message')","symbol":"ws.broadcast()","correct":"await ws.broadcast('message')"}],"quickstart":{"code":"// install\nnode ace add adonisjs-websocket\n\n// start/routes.ts\nrouter.ws('/ws', ({ ws }) => {\n  ws.on('message', (message) => {\n    ws.send('Received: ' + message.toString())\n  })\n  ws.on('close', () => {\n    console.log('Connection closed')\n  })\n  ws.send('Hello! Your id is ' + ws.id)\n})","lang":"typescript","description":"Install the package, define a WebSocket route, and handle messages."},"warnings":[{"fix":"Upgrade Node.js to v20.6.0 or later.","message":"Node.js >=20.6.0 required","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Ensure AdonisJS v6.2+ and http-server v7.0.2+ are installed.","message":"Requires @adonisjs/core ^6.2.0 and @adonisjs/http-server ^7.0.2","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Use await ws.broadcast() inside async handler.","message":"broadcast() is async, must be awaited","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use import type { WebSocketContext } from 'adonisjs-websocket'.","message":"WebSocketContext is a type only, not a runtime value","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Define handler as async ({ ws }) => { ... }.","message":"WebSocket route handlers must be async if using broadcast() or other async operations","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.2.3':9 'activ':10 'adonisj':1,6,29,40 'altern':35 'auth':31 'base':24 'broadcast':20 'control':23 'controller-bas':22 'core':30 'handl':25 'http':33 'integr':26,41 'javascript':42 'maintain':11 'middlewar':18 'provid':4,12 'registr':15 'rout':14 'router.ws':17 'seamless':27 'server':34 'socket.io':37 'support':19 'tighter':39 'v6':7 'version':8 'via':16 'websocket':2,3,13","created_at":"2026-06-07T16:48:00.921313+00:00","updated_at":"2026-06-07T16:48:00.921313+00:00","problems":[{"fix":"Run `node ace add adonisjs-websocket` to install and configure.","cause":"Package not installed or missing peer deps.","error":"Cannot find module 'adonisjs-websocket' or its corresponding type declarations."},{"fix":"Ensure handler is async and await ws.broadcast().","cause":"broadcast() used without await or on non-WebSocket context.","error":"TypeError: ws.broadcast is not a function"},{"fix":"Install @adonisjs/core v6.2+ and @adonisjs/http-server v7.0.2+.","cause":"Missing or incompatible peer dependency.","error":"Error: Cannot find module '@adonisjs/core'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/KABBOUCHI/adonisjs-websocket","github":"https://github.com/KABBOUCHI/adonisjs-websocket","docs":null,"changelog":null,"pypi":null,"npm":"adonisjs-websocket","openapi_spec":null,"status_page":null,"smithery":null,"categories":["messaging"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}