DEV Community

Cover image for Node 21 brings built-in WebSocket support
Andreas Bergström
Andreas Bergström

Posted on • Edited on

Node 21 brings built-in WebSocket support

Update 2023-10-17: Node 21 has now shipped with WebSocket support as predicted, read more:

https://nodejs.org/en/blog/announcements/v21-release-announce#built-in-websocket-client

Image description

If you're a part of the JavaScript jungle, you know how we all have been longing for some native WebSocket love in Node. WebSockets are like that secret sauce to making any app conversation go smoothly in real-time, back and forth between the client and server. But hey, Node has been playing hard to get on this one for a while. However, recent pull request activity suggest that Node version 21 might just be the game changer we've been waiting for, thanks to some community heroes putting in the elbow grease.

Now, let's talk about a recent pull request that's caught the eye over at the Undici project, which is Node’s own client for handling HTTP. This pull request is all about bringing WebSocket support to the table. It's like a beacon of hope for us, showcasing that, yeah, Node isn't going to let the modern web sprint ahead while it’s tying its shoelaces.

There’s an issue that popped up in the Node repo a while ago, which screams the community’s long-standing wish for some WebSocket magic. This thread is like a saga of devs dreaming about WebSockets dancing in Node natively.

So, what’s the big deal with WebSockets in Node? Well, it's not just about making real-time chit-chat easier; it's also about shipping Node with batteries included and gaining a small performance boost out of it. As Node version 21 is gearing up to see the daylight, having native WebSocket support could mean we get to build snazzier, more interactive apps.

Keep in mind Deno and Bun already comes with WebSocket support out of the box. Node should do to.

Read more about WebSocket at MDN.

Top comments (0)