Add WebSocket support to Express routes using the `ws` library. v1.1.0 (stable, no recent updates). Unlike `express-ws`, it uses a fake HTTP method (`WEBSOCKET`) instead of URL prefixing, supports explicit accept/reject via `cb()`, and works with detached routers. Last updated in 2016; maintained in low-activity mode.
npm install express-ws-routesNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Create an Express app with WebSocket support via express-ws-routes, define a WebSocket route, and handle connections.
Upgrade Express to 4.5.0 or later.
Avoid using 'WEBSOCKET' as an HTTP method in other middleware.
Attach the router to the app with app.use() before calling router.websocket().
Call cb() immediately in the handler.
Replace const app = express(); with const app = require('express-ws-routes')();Run npm install ws in your project.