Simple, composable Koa middleware for WebSocket handling. Version 2.1.0, actively maintained. Integrates the `ws` library as a peer dependency. Differentiates itself by being minimal (44 SLOC), unopinionated, and fully composable with other Koa middleware and routers. Supports custom context property names and passing options to the underlying `ws` server. Ships TypeScript types. Requires manual installation of `ws` and `koa` peer dependencies.
npm install koa-easy-wsVerified import paths — ran on the pinned version, not inferred.
Shows basic setup: import, middleware registration, WebSocket handling with ctx.ws, and fallback HTTP response.
Use await ctx.ws() to get the ws instance.
Run: npm install ws koa
Use app.use(websocket())
Use import easyWs from 'koa-easy-ws' or const { default: easyWs } = require('koa-easy-ws')Change app.use(websocket) to app.use(websocket())
Run: npm install ws
Upgrade to v2 and use await ctx.ws()