How to create a websocket using ws in next.js?

All the examples I found on the subject, people used socket.io, but is it possible to create a websocket using ws in next.js?